Windows BAT script to zip up the source files in a given directory

REM Windows BAT script to zip up the source files in a given directory.
REM Common VS temporary files are skipped.
REM
REM Version: 1.0
REM
REM Dependencies:
REM 7-Zip 4.42 - http://www.7-zip.org/
REM
REM Author: Sean Ryan
SETLOCAL


@ECHO OFF


IF "%1" EQU "" (
ECHO "usage: zip_source_dir.bat {directory}"
GOTO _ERROR:
)


TIME /T


SET _ZIP_PATH=%1.zip


IF EXIST %_ZIP_PATH% (
ECHO "zip file already exists! - %_ZIP_PATH%"
GOTO _ERROR:
)


"c:\Program Files\7-Zip\7z.exe" a %_ZIP_PATH% %1  -tzip -mx=3  -r  -x!*.pdb -x!*.pch -x!*.ncb -x!*.obj -x!*.bsc -x!*.ilk -x!*.il -x!*.tli -x!*.tlh -x!*.idb -x!*.sbr
IF %ERRORLEVEL% NEQ 0 (GOTO _ERROR:)


TIME /T


:_END_OK
ECHO "Finished ok"
GOTO :EOF


:_ERROR
ECHO "Exiting with error"

Comments