reckon
asked on
Batch file help needed
A friend gave me a batch file for me to configure and schedule to run my own backups, but it's not working.
Here is the original file:
@echo off
xcopy C:\Mydocu~1\*.* g:\backup\Mydocuments\*.* /k/r/y/c/h/e/f
xcopy C:\MyFile~1\*.* g:\backup\My Files\*.* /k/r/y/c/h/e/f
xcopy C:\Mypict~1\*.* g:\backup\Mypictures\*.* /k/r/y/c/h/e/f
xcopy C:\MyBusi~1\*.* g:\backup\MyBusinessInform ation\*.* /k/r/y/c/h/e/f
xcopy C:\MyCHOf~1\*.* g:\backup\MyCHOfiles-inact ive\*.* /k/r/y/c/h/e/f
xcopy C:\Docume~1\owner\*.* g:\backup\DocumentsAndSett ings\owner \*.* /k/r/y/c/h/e/f
exit
First question: What do the switches mean (/k/r/y/c/h/e/f)? I've searched online, but haven't found answers.
Second related question: I'm using Windows XP and whenever I've customized this to work on my machine (substituting the correct names and paths), it either won't work (is this because one of the users I'm trying to back up has an "&" in the name?) or, if I bypass the "&" in the command, it only performs the first five backup operations, but not the rest.
Also, where can I go to learn about simple batch files and how to troubleshoot them?
Thanks for the help--I'd like to get this resolved today, if possible, which is why I'm giving it 500 points.
Here is the original file:
@echo off
xcopy C:\Mydocu~1\*.* g:\backup\Mydocuments\*.* /k/r/y/c/h/e/f
xcopy C:\MyFile~1\*.* g:\backup\My Files\*.* /k/r/y/c/h/e/f
xcopy C:\Mypict~1\*.* g:\backup\Mypictures\*.* /k/r/y/c/h/e/f
xcopy C:\MyBusi~1\*.* g:\backup\MyBusinessInform
xcopy C:\MyCHOf~1\*.* g:\backup\MyCHOfiles-inact
xcopy C:\Docume~1\owner\*.* g:\backup\DocumentsAndSett
exit
First question: What do the switches mean (/k/r/y/c/h/e/f)? I've searched online, but haven't found answers.
Second related question: I'm using Windows XP and whenever I've customized this to work on my machine (substituting the correct names and paths), it either won't work (is this because one of the users I'm trying to back up has an "&" in the name?) or, if I bypass the "&" in the command, it only performs the first five backup operations, but not the rest.
Also, where can I go to learn about simple batch files and how to troubleshoot them?
Thanks for the help--I'd like to get this resolved today, if possible, which is why I'm giving it 500 points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That's probably the easiest solution for you at the moment, yes.
You could use the same script and pass a command line parameter in the tasks to define a target folder, but you might want to do that once you have aquired a bit more experience with batch scripts.
It would look something like that:
REM *** Target folder is passed as first argument in the command line, for example 'backupscript.cmd G:\Backup01':
REM *** Set variable TargetFolder to first argument, stripping potential quotes:
set TargetFolder=%~1
xcopy "C:\My Documents\*.*" "%TargetFolder%\Mydocument s\*.*" /k/r/y/c/h/e/f
xcopy "C:\My Files\*.*" "%TargetFolder%\My Files\*.*" /k/r/y/c/h/e/f
etc.
You could use the same script and pass a command line parameter in the tasks to define a target folder, but you might want to do that once you have aquired a bit more experience with batch scripts.
It would look something like that:
REM *** Target folder is passed as first argument in the command line, for example 'backupscript.cmd G:\Backup01':
REM *** Set variable TargetFolder to first argument, stripping potential quotes:
set TargetFolder=%~1
xcopy "C:\My Documents\*.*" "%TargetFolder%\Mydocument
xcopy "C:\My Files\*.*" "%TargetFolder%\My Files\*.*" /k/r/y/c/h/e/f
etc.
ASKER
Thanks--
ASKER
So if I wanted to backup my files to alternating directories so that no backup is overwritten until another backup exists, would the simplest solution be to have two batch files, each pointing to different backup directories and scheduled to run on alternating weeks?