- Source and Destination Directories: The script uses two variables (source and destination) to define the path of the directory to back up and the path of the backup location.
- Check Directories: It checks if the source directory exists. If not, it displays an error message and exits. It also checks if the destination directory exists. If it doesn't, the script will create it.
- Backup Process: It uses the xcopy command to copy all files and subdirectories from the source to the destination. The /s and /e options ensure that all subdirectories are included, and /y automatically overwrites existing files without prompting.
- Completion Message: After the backup, it displays a completion message.
Customizing the Script:
- Change the Source and Destination Paths: Replace C:\Path\To\Your\Source\Directory and D:\Path\To\Your\Backup\Directory with the actual paths you want to use.
How to Use This Script:
- Open Notepad and paste the script above.
- Modify the source and destination paths to your desired directories.
- Save the file with a .bat extension, such as FileBackupTool.bat.
- Double-click the .bat file to run it.
This tool can be scheduled to run regularly using Task Scheduler, ensuring your files are always backed up. It's a simple but powerful way to keep your important data secure.