I am looking to do a simple Batch process to copy log files in 3 different sub directories of the same directory to another folder elsewhere.
my code is at the moment:
for /r c:\users\...\Unzipped %%g in (*.log) do move /-y "c:\users\...\Unzipped\" "c:\users\...\Log_Files"
I continue to receive 10 responses saying my code syntax is in correct, meaning by my understanding at least the first part is somewhat correct.
The issue is with the origin part of the move command. how is it possible to say in essence, "from 3 different sub folders"?
Your original command
for /r "c:\root\folder" %%g in (*.log) do move /-y "%%~fg" "c:\target\folder"
That is, for each log file, recursively under the indicated starting folder, move the file (%%~fg
is the full path to the file being referenced by %%g
) to the target folder
If you want to directly indicate the three source folders from where the files must be taken, then
for %%g in ("c:\root\f1\*.log" "c:\root\f2\*.log" "d:\somewhere\*.log"
) do move /-y "%%~fg" "c:\target\folder"
But in this case, you can not include the /r
switch in the for
command for a recursive search.