Grouping multiple split-up RAR archives by folder with Windows batch file

If you have a folder with alot of split-up RAR archives that you need to group in sub-directories, this batch script will save you alot of time! In this example we assume the folder containing the archives is “C:\Users\Admin\Desktop\test” with archives like:

trequetry.part01.rar
trequetry.part02.rar
trequetry.part03.rar

and

replokitro.part01.rar
replokitro.part02.rar
replokitro.part03.rar
replokitro.part04.rar

and so on. We now make it so the first set of archives ends up in C:\Users\Admin\Desktop\test\trequetry and the second in C:\Users\Admin\Desktop\test\replokitro . So we are basically grouping archives based on their filename X.partX.rar where X is a variable.

Just set the folder and you’re good to go!

@ECHO OFF
SET "origloc=C:\Users\Admin\Desktop\test"
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

Leave a Reply

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