Rar all subfolders in a given folder with windows batch

What we are going to do is use winrar command line to archive all folders in a given folder in their own archive, split by ~50 megabytes, and then group all linked archives in their own subfolder.

Just set the harddisk drive letter and main folder and you’re good to go!

C:
SET "origloc=C:\RarIt"
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

One thought on “Rar all subfolders in a given folder with windows batch

Leave a Reply

Your email address will not be published. Required fields are marked *