FOR statement "unexpected i" in batch? - TechRepublic
General discussion
July 25, 2005 at 12:56 PM
dustin

FOR statement “unexpected i” in batch?

by dustin . Updated 17 years, 5 months ago

I wrote this little backup script

——-
@ECHO on
:start
::Will check day of the week and perform backup routine only if matches day specified in IF statement
FOR /F “usebackq delims==” %i IN (`date /t`) DO set date = %i
FOR /F “usebackq delims==” %i IN (`date /t`) DO set dobackup = %i
if “%dobackup%” == “*mon*” goto dobackup
else goto end

:dobackup
::moves weekly backup to weekly archive and dates one week after actual backup
move %homedrive%\weeklybackup “%homedrive%\Weekly Archive\%date%”
::copies email, favorites, cookies, my documents and desktop objects to users home directory excluding specified files.
xcopy /e /c /i /q /h /k “%userprofile%\LOCALS~1\APPLIC~1\Microsoft\Outlook” %homedrive%\weeklybackup\
xcopy /e /c /i /q /h /k “%appdata%\Microsoft\Signatures” %homedrive%\weeklybackup\
xcopy /e /c /i /q /h /k “%userprofile%\Favorites” %homedrive%\weeklybackup
xcopy /e /c /i /q /h /k “%userprofile%\Cookies” %homedrive%\weeklybackup
xcopy /e /c /i /q /h /k /exclude .mp3 “%userprofile%\*document*” %homedrive%\weeklybackup
xcopy /e /c /i /q /h /k /exclude .mp3 “%userprofile%\Desktop” %homedrive%\weeklybackup
::Dustin
:end
——–

When its run it just says “i was unexpected at this time” but seems to work when I type it into cmd and press enter, what am i doing wrong and is there a better way to do this?

This discussion is locked

All Comments