
Following the xcopy command is a string of parameters that include extra tasks: The next command sets the specific backup copy type your batch file will use, in this case, xcopy. In the example, the drive is set to "X." You should change this letter to whatever your external backup drive letter is. Regedit /e "%drive%\Registryegbackup.reg"Įcho Backup an explanation as to what the commands in this batch file mean and the bits you can customize.įirst, set the location you want to copy the files to using set drive=X:\Backup. If exist "%drive%\Registryegbackup.reg" del "%drive%\Registryegbackup.reg" If not exist "%drive%\Registry" mkdir "%drive%\Registry" %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%\Outlook" %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Identities" "%drive%\Outlook Express"Įcho # Backing up email and contacts (MS Outlook). %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Address Book" "%drive%\Address Book" %backupcmd% "%USERPROFILE%\Favorites" "%drive%\Favorites"Įcho # Backing up email and address book.

%backupcmd% "%USERPROFILE%\My Documents" "%drive%\My Documents" Set backupcmd=xcopy /s /c /d /e /h /i /r /y This time you will build a longer string of folders to backup, including your system registry and other important folders. The easy backup method works best for backing up individual folders, but isn't entirely practical for anything more complex. Now, head to File > Save As, name the file systembackup.bat, and complete the Save.

ROBOCOPY C:\your\filename\goes\here C:\your\backup\location\goes\here /LOG:backuplog.txt Open Notepad, then input the following commands: off Below are instructions for a basic backup batch file and another slightly more advanced version. There are many different batch file backup methods you can use. Sometimes, it pays to make a couple of copies of anything that might make you cry if it were deleted or destroyed. You should use system backup and system restore points as part of your regular system maintenance. You can use a batch file to backup a specific folder or as part of a more substantial backup setup. Automate System Backup Using a Batch File /c del is the delete aspect of the commandģ.Increase or decrease depending on your requirements We used the wildcard operator "*" in our first example, and specified. /m instructs the command to use the given search mask./s instructs the command to search sub-directories.the directory you want to delete the files from /p details the path to start searching i.e.the commands will apply to each file fitting the command arguments forfiles allows us to use commands for each file in a location i.e.docx /d -3 /c "cmd /c del batch file commands and switches in use here are:

docx file extension older than three days: forfiles /p "C:Īme\here" /s /m *. The first example deletes files in the specified folder older than three days: forfiles /p "C:Īme\here" /s /m * /d -3 /c "cmd /c del second example only deletes files with the. Furthermore, you can use the batch file script to delete a specific file type or a group of files in a folder, so long as they meet the criteria expressed in the commands. You set the maximum age range for the files in the batch file, allowing you to customize the process. You can use a batch file to scan for and then delete files older than a certain amount of days. Delete Files Older Than a Certain Time Using a Batch File
