Reputation: 608
I have a very simply batch file that I am trying to execute. The premise of it is simple: for every user, copy a folder and all its contents into another folder. However, upon executing I am unsuccessful. I do not get any error messages and it exits out immediately. I have ran the xcopy command itself with success, so this leads me to believe I am doing something wrong with the for loop. My knowledge with command prompt is relatively limited, so please pardon my ignorance in regards to the subject. Thanks for any help!
for /f "delims=" %a in ('dir /b /ad C:\Users') do xcopy C:\Folder "C:\Users\%a\AppData\Roaming\Folder" /f /j /s /w /y
Upvotes: 2
Views: 2127
Reputation: 3690
It works for me from the command line (replacing xcopy
with echo xcopy
). From a batch file, though, you'll need to double your %
signs, so make sure you're using %%a
instead of %a
.
Upvotes: 2