I seem to be stuck with a batch script and would like some help.
Basically I need to check if a file exists in a folder in the %localappdata% and if it does then overwrite the file and if not place inside a different location so at the moment it reads like this:
IF EXIST "%localappdata%\foldername\filename" COPY /Y "filename" "location" ELSE COPY "filename" "location2"
But when this runs I’m receiving an error of The syntax of the command is incorrect. This seems to be down to the %localappdata% variable being used.
Thank you in advance for any help on this.
You need to put the two commands for the
IFbranches in parens:The reason for this is that the shell needs to be able to tell that if the file does exist, the command you want to run is just this:
and not all of this:
If you think about it, all those
ELSE COPYstuff may very well be legitimate parameters for the firstCOPY— the shell has no way to know unless you help.