Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Windows batch zip project files with date stamp (legacy backup method by Schedule)
@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"
for %%a in (%arg%) do %zip_exe%\7z.exe a -tzip "%destination%\" "%%~na" -xr@"%config_file%\archive_exclude.txt"
rem echo for %%a in (%arg%) do xcopy "%destination%\" "%dropbox_bak%" /Y
rem for %%a in (%arg%) do xcopy "%destination%\" "%dropbox_bak%" /Y
rem for %%a in (%arg%) do xcopy "%destination%\" "%destination2%" /Y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment