I wrote this batch file and I am trying to get it to run in cmd prompt but I keep getting a syntax error on the FOR loop. I just want to copy files to computers on my network.
Here is the code for the batch file.
The complist file contains
PC1
PC2
PC3
What is wrong?
set FILE2COPY = C:\test1\[login to view URL]
set COMPLIST = C:\test1\[login to view URL]
for /f %%a in ("%COMPLIST%") do (
set WIN7 = \\%%a\c$\Program Files (x86)\test1
set WINXP = \\%%a\c$\1test
if EXIST "%WIN7%" (set COPYDIR =%WIN7%
)
else ( if EXIST "WINXP" ( set COPYDIR =%WINXP%
)
else ( ECHO No such directory exists for computer %%a
pause
GOTO :END
)
)
copy "%FILE2COPY%" "%COPYDIR%" /Y
)
Pause
:END
Hello,
With 99% completion rate, 650+ successfully completed projects, and a 5.00 reputation (maximum possible, 5.0) (Yes, not even 4.99 !!)... you can never go wrong choosing me :)
I look forward to your reply.
Thanks.
Kind Regards,
Rajesh Soni
Hello!
I have identified and corrected several errors in your batch file.
Basically, I can deliver you a corrected batch file within minutes after you award me the project and I accept it (please allow for time difference for initial contact).
I have more than 20 years experience with PCs, going back to times of DOS when running batch files at command prompt were the only way one could automate things.
I'm confident that I can do this job to your highest satisfaction.
Best regards,
Tom
Hello. What exactly are you trying to get your for loop to do? And could you also send the error you receive? Thank you for your time and I look forward to working with you. Edit: Offhand I can see that you will most likely need to use either quotes "" around Program Files (x86) or use a short filename such as PROGRA~2 in your path.