@ECHO OFF Rem -- Prepare the Command Processor SETLOCAL EnableExtensions EnableDelayedExpansion Title testIZArc.bat Rev2c REM Use IZArc command-line Add-on to zip files and dirs in user defined REM folder %zipdir% and move the zip archive to user defined folder %movedir% REM Added option for user to name archive file and completely empty zipdir 04-02-20 REM ---- Set console version for the IZArc CL Add-on (change as requred) ----- set path="C:\Program Files\IZArc\";%path% REM -------------------------------------------------------------------------- REM ---------- Set location of folder to zip (change as requred) ------------- set "zipdir=c:\zipdir" REM -------------------------------------------------------------------------- REM ------ Set location of folder for moved archive (change as requred) ------ set "movedir=c:\movedir" REM -------------------------------------------------------------------------- REM Check executable path, and existence of zipdir and movedir set /A "e=0" & set /A "z=0" & set /A "m=0" IZARCC.exe > NUL 2>&1 IF NOT %ERRORLEVEL%==9009 ECHO Executable path OK IF %ERRORLEVEL%==9009 ECHO IZARCC.exe does not exist in path && goto end if exist "%zipdir%" if exist "%movedir%" ECHO zipdir and movedir OK if not exist "%zipdir%" ECHO zipdir doesn't exist && set /A "z=1" if not exist "%movedir%" ECHO movedir doesn't exist && set /A "m=1" if %e% == 1 goto end if %z% == 1 goto end if %m% == 1 goto end ECHO. REM -------------------------------------------------------------------------- REM Change working dir to %zipdir% pushd %zipdir% REM Replace space in hour with zero if it's less than 10 SET hr=%time:~0,2% IF %hr% lss 10 SET hr=0%hr:~1,1% REM This sets the date like this: mm-dd-yr-hrminsecs1/100secs Set TODAY=%date:~4,2%-%date:~7,2%-%date:~10,4%-%hr%%time:~3,2%%time:~6,2%%time:~9,2% REM Set name of archive for the contents of %zipdir% set myfolder= set /p myfolder=Enter an archive name for files and dirs in "%zipdir%": ECHO Directory to zip: %zipdir% ECHO Move archive to: %movedir% ECHO Archive Name: %myfolder% REM to zip only files change "%zipdir%\" to "%zipdir%\*.*", "%zipdir%\*.txt", etc. ECHO. ECHO Zipping all contents of %zipdir% and moving archive to %movedir% ECHO. izarcc -a -cx -r -p "%movedir%\%myfolder%_%TODAY%.zip" "%zipdir%\*.*" ECHO. REM Delete entire contents of "%zipdir%" call:ask ECHO. ECHO Task Complete ... ECHO. ECHO Press any key to exit ... pause > NUL EXIT /B 0 :end ECHO. ECHO zipdir, movedir don't exist, or error in IZArc CL Add-on path ECHO Create zipdir, movedir, or correct executable path above ECHO Exiting script ECHO Press any key to exit ... pause > NUL ECHO EXIT /B 0 :ask set INPUT= set /p INPUT=Delete original files and dirs in "%zipdir%"^?(y/n): if not defined INPUT goto ask if /i "%INPUT:"=%"=="y" goto yes if /i "%INPUT:"=%"=="n" goto no echo Incorrect input, try again & goto ask :yes echo deleting contents from "%zipdir%" ... del /q "%zipdir%\*" for /d %%x in ("%zipdir%\*") do @rd /s /q "%%x" goto :eof :no echo. echo No files or dirs deleted from "%zipdir%" goto :eof