Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
:: Don't echo all the text to the command window
@echo off
:: Create a copy from D:\ImportantStuff\Pictures directory to the local directory HomeBackups\Pictures
:: Robocopy's /mir switch will only copy files if they change or don't exists in the destination directory
robocopy D:\ImportantStuff\Pictures HomeBackups\Pictures /mir
:: Copy D:\Music to HomeBackups\Music
robocopy D:\Music HomeBackups\Music /mir
:: Create a variable with the current date in the format 'yyyy-mm-dd'
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
:: Create a variable with the current time in it
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
:: Write the current date and time to a file named lastBackup.txt.
:: This file will store the time of the last successful backup
echo %mydate%_%mytime% > lastBackup.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.