Last active
June 15, 2022 19:50
-
-
Save leodecm3/7814cfdd13ad51e1b42aa26f532d7160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: --------- set the variables for exemple _yyyy is 2022 ------------------------------------------------------- | |
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO ( | |
IF "%%~L"=="" goto s_done | |
Set _yyyy=%%L | |
Set _mm=00%%J | |
Set _dd=00%%G | |
Set _hour=00%%H | |
SET _minute=00%%I | |
SET _second=00%%K | |
) | |
:s_done | |
Set _mm=%_mm:~-2% | |
Set _dd=%_dd:~-2% | |
Set _hour=%_hour:~-2% | |
Set _minute=%_minute:~-2% | |
Set _second=%_second:~-2% | |
:: --------- set the variables with the name of the folder ------------------------------------------------------- | |
set myDIR=..\BACKUP_%_yyyy%%_mm%%_dd% | |
:: --------- ask the user before starting copying ------------------------------------------------------- | |
cls | |
ECHO OFF | |
ECHO . | |
ECHO . | |
ECHO . I WILL CREATE A BACKUP IN THE FOLDER: | |
ECHO . %myDIR% | |
ECHO . | |
ECHO . | |
ECHO . CLOSE THIS WINDOW TO ABORT! | |
pause | |
ECHO ON | |
:: --------- here is the magic! ------------------------------------------------------- | |
::I copy from this folder "." | |
::To the folder %myDIR% | |
::with all subfolders /E | |
::Multithreading 16 times faster /MT:16 | |
::In case of faliure wait 5 seconds /W:5 | |
::Deletes destination files and directories that no longer exist in the source. /PURGE | |
robocopy "." %myDIR% /E /MT:16 /W:10 /PURGE | |
::ask the user to click anywhere to close | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment