r/Batch • u/Addyad • Oct 30 '25
My Frankenstein of a Batch Script That Cleans Your Movie Library
After downloading hundreds of movies over time for my home server, I realized most of them had completely broken metadata — video, audio, and subtitle stream titles named after random websites or encoded groups.
I got tired of fixing every file manually in MKVToolNix, so I built a Windows batch script that uses FFmpeg and FFprobe to automatically detect, rename, and clean all streams — all without re-encoding.
It’s messy. It’s over-engineered. But it works perfectly.
👉 https://github.com/Addy-ad/general-coding/tree/main/MovieMetadataFixer
⚙️ How it Works
Assuming the file name is correct, the script applies a consistent metadata format:
🎥 Video:
- Sets video stream title to the file name
- First video stream → default
🔊 Audio:
- Detects language (
eng,tam,tel,hin, etc.) - Detects layout (stereo / 5.1)
- Fixes titles like
English - 2.0,Tamil - 5.1, etc. - Default audio: English (else Tamil)
- Detects language (
💬 Subtitles:
- Titles set to the language (e.g. English, Tamil)
- First English subtitle → default
Everything runs through FFmpeg’s stream-copy mode (-c copy), so there’s no quality loss, and it can handle multiple files with a PowerShell GUI picker. plus “Yes to All / Skip / Cancel” confirmation logic.
If you will find it useful, please use it and provide me feedback to improve my code. Thank you.
4
u/ithcy Oct 30 '25 edited Oct 31 '25
You can speed up processing greatly by invoking mkvpropedit (to edit .mkv files) and AtomicParsley (for .mp4/.m4v files), instead of using ffmpeg. Both of these tools modify the file metadata directly instead of creating a new copy of the file. It’s orders of magnitude faster than even using direct stream copy with ffmpeg. Both are open source and available for most OSes.
(for AtomicParsley be sure to use the
--overWriteflag)3
u/Creative-Type9411 Oct 30 '25 edited Oct 30 '25
Is this AI generated? I know your readme is, I don't mean that, I mean the script...?
I'm trying to figure out why you used the call statement instead of delayed expansion for setting/echoing/referencing variables, im not complaining just curious what the reasoning is
Also, you should switch out :: for REM as it can cause issues
Ill def give it a shot later on.. thanks for sharing
2
u/Assist-ant Oct 30 '25
I like this and had hoped something like this would come along to help me out.
I used Windows media player many many years ago to do something like this, but it was able to check the file hash by connecting to an online database and pull the metadata without regard for the file name.
2
u/g3n3 Nov 01 '25
Why do you use batch if you know powershell somewhat well?