windows - Batch Script - IF EXIST copy to %localappdata% error -


i seem stuck batch script , help.

basically need check if file exists in folder in %localappdata% , if overwrite file , if not place inside different location @ moment reads this:

if exist "%localappdata%\foldername\filename" copy /y "filename" "location" else copy "filename" "location2"  

but when runs i'm receiving error of the syntax of command incorrect. seems down %localappdata% variable being used.

thank in advance on this.

you need put 2 commands if branches in parens:

if exist "%localappdata%\foldername\filename" (copy /y "filename" "location") else (copy "filename" "location2") 

the reason shell needs able tell if file exist, command want run this:

copy /y "filename" "location" 

and not of this:

copy /y "filename" "location" else copy "filename" "location2" 

if think it, else copy stuff may legitimate parameters first copy -- shell has no way know unless help.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -