I have some files (207 RAR files downloaded), and they don't have a proper name to refer each part/index, and if I want to extract them I should name them manually by checking volume index (from Properties section), and as you notice that can be too time-consuming
I thought that I might do it using a batch or a python script, so the first thing I needed to do is to get the volume index from CMD "7z i FileName.rar", but I couldn't find the volume index number (or maybe HEX) from the output Am I using the wrong command? Or maybe it is printed but I can't find it?
I attach one of RAR files output (Volume index is 18 [It is 19th part]) https://www.pastiebin.com/5cee55060c642
I would be thankful if you can help me.
You should be able to accomplish this with the l
(list) command.
Here is a simple Windows command:
for %a in (*.rar) do @ECHO %a & "C:\Program Files\7-Zip\7z.exe" l %a | FIND "Index" & ECHO.
Here is the batch file version (%%
instead of %
):
@ECHO off
for %%a in (*.rar) do ECHO %%a & "C:\Program Files\7-Zip\7z.exe" l %%a | FIND "Index" & ECHO.
This will echo the filename and the "Volume Index" field from the output of the l
(list) command for that file like the example below:
myFile.part1.rar
Volume Index = 0
myFile.part2.rar
Volume Index = 1
myFile.part3.rar
Volume Index = 2
To rename all of the files in order, you can use the following batch file.
Warning This will affect all files in the directory it's run in and the original file names will be lost.
@ECHO off
SET PATH=%PATH%;C:\Program Files\7-Zip\
for %%a in (*) do CALL:Index "%%~a"
GOTO:EOF
:Index
ECHO %~1
SETLOCAL EnableDelayedExpansion
for /f "tokens=3 delims== " %%a in ('7z.exe l "%~1" ^| FIND "Index"') do CALL:Rename "%~1" %%a
ENDLOCAL
GOTO:EOF
:Rename
SET /A Index=%2+1
REN "%~1" file%Index%.rar