Reputation: 87
I'm trying to accomplish 2 things and I'm not sure the best way.
copy new or modified files from a windows source to another windows server and log the transaction (completed and logged using Robocopy), e.g.:
ROBOCOPY /XO /XX /Z /V /BYTES /LOG:\ServerB\Log.txt \ServerA\source \ServerB\target *.txt /A-:A
create a simple list (control file for another process) of just the file names that were copied above, to a new file without any of the other details, e.g.:
file1.txt
file2.txt
file3.txt
I considered running the Robocopy statement twice, once with /L and writing it to a log then running the same statement without /L and writing it to a log to get what I need but I haven't been able to find a way to generate a simple log file with only the successful file names (like example above)
Upvotes: 1
Views: 2596
Reputation: 206
I am not quite clear whether you only want to have the copied files in the log or even the non-copied same files. You can omit the /Verbose option, then you do not need to hide as many states. Do you need this log to create the list for the other process or is it intended for the documentation?
If the LOG is intended for the documentation, then you can rattling everything without option /L in a loop.
setlocal
for /f "delims= " %%t in ('robocopy . . /njh /njs')do set "tab=%%t"
3>controlfile (
for /f "tokens=3 delims=%tab%" %%i in ('robocopy /xx /xo /Z /bytes \\ServerA\source \\ServerB\target *.txt /tee /LOG:\\ServerB\Log.txt
') do >&3 echo %%i
)
Upvotes: 1