Batch extract multi-part .rar archives (including .r00, .r01, … pieces)
and remove the archive files once the extracted video shows up.
- 7-Zip command line tool (
7z) installed and available in yourPATH. - Python 3.8 or newer.
python batch_unrar_clean.py /path/to/"tv shows"This command:
- Walks through every subdirectory underneath the root.
- Extracts each
.rararchive (skipping anypart2,part3, … files so they are only processed once). - Looks for new video files (
.mkv,.mp4,.avi,.mov,.wmv,.flv,.ts,.m4vby default). Only when a new video appears do the archive parts get deleted, giving you a safety net for corrupt archives.
--dry-run— show what would be done without extracting or deleting files.--extractor PATH— use a different command than7z(e.g.7zzon some systems).--video-ext EXT— watch for additional video extensions (use multiple times if needed). Example:--video-ext webm.
Tip: On Linux/macOS install the extractor via
sudo apt install p7zip-fullorbrew install p7ziprespectively.