Skip to content

Instantly share code, notes, and snippets.

@uchiiii
Last active November 22, 2018 13:12
Show Gist options
  • Save uchiiii/6452dc8ec8ed4658f6a8634fbdcd9e7f to your computer and use it in GitHub Desktop.
Save uchiiii/6452dc8ec8ed4658f6a8634fbdcd9e7f to your computer and use it in GitHub Desktop.
This is used to backup your file or folder on Windows.
@echo off
setlocal
rem FROM refers to the source of your folder or file that you want to backup.
set FROM=<ABSOLUTE_PATH>
rem TO refers to the destination.
set TO=Z:<ABSOLUTE_PATH>
set LOG=%~dp0\autocopy.log
rem EXCEPT refers to files that you don't want to backup.
set EXCEPT=<ABSOLUTE_PATH>
set OPT=/MIR /R:3 /W:10 /V /FP /DCOPY:T /LOG:%LOG% /XD:%EXCEPT% /TEE
if not exist %FROM% goto error1
if not exist %TO% goto error2
robocopy %FROM% %TO% %OPT%
goto end
:error1
echo Path-> %FROM% is invalid.
goto end
:error2
goto Path-> %TO% does not exist.
goto end
:end
endlocal
@uchiiii
Copy link
Author

uchiiii commented Nov 21, 2018

How to use

step1: Download this script onto your PC on windows.
step2: Change the three different <ABSOLUTE_PATH> on it so that it operates as you want.
step3: Put .\autocopy.bat to execute the backup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment