Compress all Subfolders in a Folder

First, set the current drive at the prompt:

C:

and the location to the folder to compress with WinRAR:

SET "origloc=C:\RarIt"

after that, run the script:

cd %origloc%
for /D %%s in (.\*) do "C:\Program Files (x86)\WinRAR\rar.exe" a -ep -ep1 -m0 -v50000 -df "%%s.rar" "%%s"
 
@ECHO OFF
FOR %%F IN ("%origloc%\*.part*.rar") DO CALL :process "%%F"
GOTO :EOF
 
:process
CALL :checkpath "%~dpn1"
MOVE %1 "%subfolder%" >NUL
GOTO :EOF
 
:checkpath
SET "subfolder=%~dpn1"
IF NOT EXIST "%subfolder%\" MKDIR "%subfolder%"
GOTO :EOF
 
pause