@echo off
:: Creates a RAR archive of files and moves them to a specified directory
:: size of rar archives in kilobytes
set /a rarsize_kb=200000
:: extension of files to move
set extension=".avi"
:: directory to move files to
set target_dir="C:\UPLOAD"
call :loop %*
goto :EOF
:loop
IF "%~1"=="" goto :EOF
::::: move if extension match, pack otherwise :::::
IF "%~x1"==%extension% (
move "%~f1" %target_dir%
) ELSE (
"%ProgramFiles%\WinRAR\Rar.exe" a -k -y -rr -ep1 -m0 -v%rarsize_kb% -w"%~dp1" "%~f1.rar" "%~f1"
move "%~f1*.rar" %target_dir%
)
shift
goto :loop