Вопрос

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
Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top