Reputation: 21
I need a batch file that will search all subfolders in a folder, find any folder named Reports
(there will be many and file paths will be changing constantly) and then copy the reports folders contents (not the folder) back to a root directory for export. For example: I have a folder on my desktop called Cases
. I need to search all sub folders for folders called Reports
and then copy those files out.
Any help would be appreciated.
Upvotes: 1
Views: 690
Reputation: 5504
Here is a way you can do it (assuming you are talking about Cases
folder in your desktop [in cmd]):
for /R "%userprofile%\Desktop\Cases" /D %A in (Reports.?) do @xcopy /s %~fA full_path_you_want
For batch file you should double the percent-signs (%%
) just like this:
@echo off
for /R "%userprofile%\Desktop\Cases" /D %%A in (Reports.?) do xcopy /s %%~fA full_path_you_want
To learn more about commands and wildcards (.?
) you can:
Type for /?
in a fresh cmd
Check link https://www.robvanderwoude.com/battech_wildcards.php
Hope this helps!
Upvotes: 1