@echo off @setlocal REM compress_rar.bat REM This compresses files in a folder specified by the user individually or in a single REM archive in *.rar format (WinRAR's default). REM Subfolders are not included, but REM can be added by adding the -r switch to the command (i.e. rar a -r %%~ni %%i) REM Note: files with the same name but with different extentions will be in the same archive REM Specify the folder to compress below: REM -------------------------------- Folder to compress--------------------------------- set dir=C:\folder_to_compress\ REM ------------------------------------------------------------------------------------ REM change to directory cd %dir% REM Path to WinRAR executable in Program Files set path="C:\Program Files\WinRAR\";%path% 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% echo. echo All files in %dir% to be compressed echo. ECHO Select to compress files individually (i) or in one archive (s) set /P PROFILE=Use lowercase! (i=individually, s=one archive): if "%PROFILE%"=="i" goto indiv if "%PROFILE%"=="s" goto onearc :indiv echo. echo. FOR %%i IN (*.*) do ( rar a "%%~ni" "%%i" ) goto eof :onearc echo. echo. echo Today's date and time will be added to the base filename set /P name=Enter base filename for archive: rar a "%name%_%today%" :eof echo. echo "Task Completed" echo. @pause