Compress and archive files with WinRAR command line

Whatever project you are working on it is always good to make a backup or an archive every once in a while.

This batch file will quickly make a .rar archive of a given folder, time stamp it and put the archive in a desired folder.

This way you can quickly make a snapshot of all your files in case something goes wrong :smile:

set rardirectory="C:\Program Files\WinRAR\Rar.exe"
set /P c=Are you sure you want to continue[Y/N]?
if /I "%c%" EQU "Y" goto :continue
if /I "%c%" EQU "N" goto :leave
goto :choice

set source="C:\test\source\"
set destination="C:\test\destination\"
if not exist %destination% mkdir %destination%
echo SOURCE: %source%
echo: DESTINATION: %destination%

%rardirectory% -dh -r  a -agYYYY-MM-DD-HH-MM-SS %destination% %source% -ep1 -r -m5

%SystemRoot%\explorer.exe "%destination%"