Skip to content

Instantly share code, notes, and snippets.

@kfparri
Created April 4, 2016 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfparri/e23f3e561d90487aa6cb90aaa853c3ee to your computer and use it in GitHub Desktop.
Save kfparri/e23f3e561d90487aa6cb90aaa853c3ee to your computer and use it in GitHub Desktop.
:: 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