Reputation: 1
I am trying to run a command that copies all files from one folder with subfolders into anther folder, but without any subfolders...
I have this:
for /r d:\uploadfolder %f in (*) do @copy "%f" d:\test /y
It works perfectly if I paste it into the command prompt. But if I save it into a .bat file and try to run it I get the following error:
f" d:\test /y was unexpected at this time
Can anyone point out what I'm doing wrong!
I am trying this on Windows Server 2003.
Many thanks.
Upvotes: 0
Views: 85
Reputation: 8205
Change %f
to %%f
. When in a batch file, you need to use two %
characters, as specified in the help of the for
command.
Upvotes: 3