Creating a simple batch file to backup files or folders is a cool way to move, copy, and backup any file you like.
A batch file is a text file saved as a .bat extension and when doubled clicked on it will execute the dos commands contained in that file.
In this article I will be using the xcopy command and the robocopy command to create a batch file to copy a file or folder. If you have Windows XP you will use xcopy for your batch file and if you have Windows Vista you can use the new command, robocopy.
How to create a batch file
- Open Notepad by going to the start menu>all programs>accessoires>then choose Notepad.
- Type your commands into the notepad file.
- Then go to the file menu at the top and choose Save As.
- Now save the file as Yourfilename.bat
Some examples on what to write in a batch file to copy or backup files
xcopy “C:Documents and SettingsYour usernameMy DocumentsMy Pictures” “H:backup of pictures” /e /y
This command will backup my pictures on C: drive and paste it to H: drive in a folder called backup of pictures. If you put the destination as just H: than all the files will be all over the place. You must specify a folder. I usually make a new folder first. Of course you can also get the batch file to make the new folder for you but this is another article altogether.
/e means to copy all directories and sub directories
/y means to copy with prompting to overwrite the already exsisting files
See more xcopy commands.