How to Backup Your Computer Files and Photos with a Batch File
First, let me assure you I'm going to show you a much easier solution in the end, but batch files are a very easy and free solution to backing up all kinds of files on your hard drive from family photos to important work documents. Read on to find out more about this solution that's been around since the DOS days....
What is a Batch File
A batch file is a text file with a series of command line commands in them. When you execute a batch file by double clicking on it a black box will appear on your screen. This is a DOS box. I can be minimized so you may continue to work on other tasks while the batch file is running. If this is your first time running the batch file you may want to keep the box open so you can see if there are any errors.
How Do I Make a Batch File
Open your explore window.
Left mouse click on File
Left mouse click on New
Left mouse click on Text File
Name your text file something like Backup
Now double click on your file
Now Click File
Save As
Below where you see *.txt click the pull down menu on Save As Type
Left mouse click on All Files
Type in Backup.bat
The bat ending tells Windows this is an executable file
Now Here's How You Make Your Backup.bat
You're going to use a copy program built into Windows called xcopy. It does a lot more than the copy command.
Since you're backing up you're going to back your files onto a USB Thumb Drive
So follow the procedure above to place your bat file on your thumb drive.
Right mouse click on your bat file
Left mouse click on edit
A white window opens up looking like a text file
Assuming c is your hard drive, type this into your first line
xcopy c:\*.htm /s/d/y/c/
Now click File
Click Save
Click File
Click Exit
You just wrote your first batch file!
Here's What You Did
xcopy is a command line program. It can be used in XP's run command as well as a batch file.
c: \ means your hard drive's root directory (folder). It's where all other folders start. Note the \ not the / in which internet users are acustom.
* means wild card. Anything
htm covers both htm and html files which are web page files you keep backed up on your hard drive (you do keep a backup of your website on your hard drive right).
\ means the root of where your computer thinks you are right now. One problem with USBs is they shift drive letters. By running your batch file from your thumb drive you bypass this problem.
Now We Get to The Xcopy Switches
/s means subfolder. This orders xcopy to copy files below, in this case, the root folder (used to be called a directory). This also creates the subfolders on the backup thumb drive.
/d means date. If you don't place a :date after the /d xcopy only overwrites file if the file is newer than the one it is going to overwrite.
/y means yes, go ahead and overwrite the older file and don't ask every time.
/c means to continue even if there is an error copying the file.
Now if you double click on your backup.bat you can watch it run (not responsible for damage to your computer blah blah blah).
Conclusion
There's a lot more to it than this obviously. Command lines don't like spaces in folders for example so you need to use quotes. This will, however give you your start in the world of backups and batch files. Remember, it isn't IF your hard drive will crash, IT WHEN.
What is a Batch File
A batch file is a text file with a series of command line commands in them. When you execute a batch file by double clicking on it a black box will appear on your screen. This is a DOS box. I can be minimized so you may continue to work on other tasks while the batch file is running. If this is your first time running the batch file you may want to keep the box open so you can see if there are any errors.
How Do I Make a Batch File
Open your explore window.
Left mouse click on File
Left mouse click on New
Left mouse click on Text File
Name your text file something like Backup
Now double click on your file
Now Click File
Save As
Below where you see *.txt click the pull down menu on Save As Type
Left mouse click on All Files
Type in Backup.bat
The bat ending tells Windows this is an executable file
Now Here's How You Make Your Backup.bat
You're going to use a copy program built into Windows called xcopy. It does a lot more than the copy command.
Since you're backing up you're going to back your files onto a USB Thumb Drive
So follow the procedure above to place your bat file on your thumb drive.
Right mouse click on your bat file
Left mouse click on edit
A white window opens up looking like a text file
Assuming c is your hard drive, type this into your first line
xcopy c:\*.htm /s/d/y/c/
Now click File
Click Save
Click File
Click Exit
You just wrote your first batch file!
Here's What You Did
xcopy is a command line program. It can be used in XP's run command as well as a batch file.
c: \ means your hard drive's root directory (folder). It's where all other folders start. Note the \ not the / in which internet users are acustom.
* means wild card. Anything
htm covers both htm and html files which are web page files you keep backed up on your hard drive (you do keep a backup of your website on your hard drive right).
\ means the root of where your computer thinks you are right now. One problem with USBs is they shift drive letters. By running your batch file from your thumb drive you bypass this problem.
Now We Get to The Xcopy Switches
/s means subfolder. This orders xcopy to copy files below, in this case, the root folder (used to be called a directory). This also creates the subfolders on the backup thumb drive.
/d means date. If you don't place a :date after the /d xcopy only overwrites file if the file is newer than the one it is going to overwrite.
/y means yes, go ahead and overwrite the older file and don't ask every time.
/c means to continue even if there is an error copying the file.
Now if you double click on your backup.bat you can watch it run (not responsible for damage to your computer blah blah blah).
Conclusion
There's a lot more to it than this obviously. Command lines don't like spaces in folders for example so you need to use quotes. This will, however give you your start in the world of backups and batch files. Remember, it isn't IF your hard drive will crash, IT WHEN.
Source...