Reputation: 5633
I have this line in a Windows batch file:
dir /a-d "E:\Reports_PreDelivery\*" && (xcopy /D /V E:\Reports_PreDelivery\* \\ServerName\Folder\Procedures)
This all works correctly. I'd like to log the output to a file, so I tried:
dir /a-d "E:\Reports_PreDelivery\*" && (xcopy /D /V E:\Reports_PreDelivery\* \\ServerName\Folder\Procedures) >> C:\logs\reports_transmit.log
The output redirect doesn't seem to work. The directory listing still shows up in the cmd window (instead of redirecting) and then hits a "File not found" error like it's trying to run dir
for something incorrectly. I also tried 2>&1
at the end too, no luck.
Upvotes: 0
Views: 424
Reputation: 130839
Your redirection is in the wrong place. It is only being applied to the conditional XCOPY command.
Try placing parentheses around everything, and redirect outside of that.
(dir /a-d "E:\Reports_PreDelivery\*" && xcopy /D /V E:\Reports_PreDelivery\* \\ServerName\Folder\Procedures) >>C:\logs\reports_transmit.log 2>&1
Upvotes: 1