Created
April 26, 2019 11:29
-
-
Save simongcc/eb55c4e9c55ccd73ffa48f3083081ba5 to your computer and use it in GitHub Desktop.
Windows batch zip project files with date stamp (legacy backup method by Schedule)
This file contains hidden or 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
| @echo off | |
| rem get local date time | |
| for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j | |
| rem set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,6% | |
| set ldt=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2%-%ldt:~8,2%%ldt:~10,2%%ldt:~12,2% | |
| set destination=U:\Project-by-Set-Grp | |
| set destination2=Z:\_Project_Bak | |
| set zip_exe="C:\Program Files\7-Zip" | |
| set config_file="C:\Users\XXXXX\Dropbox\_work\_backup_data" | |
| set dropbox_bak="U:\Project-by-Set-Grp" | |
| rem get the drag N drop filename and zip | |
| set "arg=%*" | |
| set "arg=%arg:)=^)%" | |
| set "arg=%arg:(=^(%" | |
| rem for %%a in (%arg%) do echo %%~fa | |
| rem zip multiple folder by dragging to this batch file | |
| echo %arg% | |
| echo %destination% | |
| echo %zip_exe% | |
| rem for %%a in (%arg%) do echo "%destination%\%%~na-%ldt%.zip" "%%~na" | |
| for %%a in (%arg%) do %zip_exe%\7z.exe a -tzip "%destination%\%%~na-%ldt%.zip" "%%~na" -xr@"%config_file%\archive_exclude.txt" | |
| rem echo for %%a in (%arg%) do xcopy "%destination%\%%~na-%ldt%.zip" "%dropbox_bak%" /Y | |
| rem for %%a in (%arg%) do xcopy "%destination%\%%~na-%ldt%.zip" "%dropbox_bak%" /Y | |
| rem for %%a in (%arg%) do xcopy "%destination%\%%~na-%ldt%.zip" "%destination2%" /Y | |
| pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment