

You may also want to check the following source that contains additional guides about batch scripts. The unix time stamp is a way to track time as a running total of seconds. (4) Once you double-click on the batch file, the backup with the timestamp will be created at your target path. Here, let’s save the file as ‘ Backup.bat‘ Set BackupName=Backup_Products_%Yr%-%Mon%-%Day%_(%Hr%-%Min%-%Sec%)Ĭopy "C:\Users\Ron\Desktop\Test\Products.csv" "C:\Users\Ron\Desktop\Test\%BackupName%.csv" The target path to the location where you want to store the backup fileĪs mentioned before, don’t forget to add the file type at the end of the paths (here, the CSV file type is “.The source path to the location where your original file is stored.
#FILE TIME STAMP CODE#
(2) Then, type/copy the code below into Notepad. Let’s now see the steps to create a batch script to backup a CSV file called ‘ Products‘ where the file type is “. Example with the Steps to Create the Batch Script Right click to Restart Explorer, then Restart PC. This represents the target path where your backup file will be storedĭon’t forget to put the file type at the end of the paths (for example, for a CSV file, the file type is “.csv”). 1) Right click Start button to open Task Manager, show More Details, then choose Processes tab, scroll down to Windows Processes, then further down to Windows Explorer. “Path where your backup file will be stored\%BackupName%.File Type” You’ll have to ensure that the file name specified is identical to the original file name This is the source path where your original file is stored. “Path where your file is stored\File Name.File Type” You may change the file name and/or timestamp format

#FILE TIME STAMP FULL#
This is the full file name with the timestamp format (this file name will be created when you execute the batch script). You may customize the following parts in the code based on your needs: BackupName=File Name_%Yr%-%Mon%-%Day%_(%Hr%-%Min%-%Sec%) Set BackupName=File Name_%Yr%-%Mon%-%Day%_(%Hr%-%Min%-%Sec%)Ĭopy "Path where your file is stored\File Name.File Type" "Path where your backup file will be stored\%BackupName%.File Type" Here is the batch script that you can use to generate your backup file: offįor /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set DateTime=%%a Batch Script to Generate a Backup File with Timestamp In this guide, you’ll see the full steps to create a backup file with a timestamp using a batch script.
