Batch removing attachments

mkvtoolnix is great and its been a big help for me. I like the GUI. I found a process for batch removing non english content (audio, subs) which is very convenient and found a script online for batch removing video titles ( so they take on the filename instead) which is also very useful.

However I still don’t know how to batch remove attachments/fonts ( not the subs themselves ). These can sometimes take up a lot of space especially when dealing with a lot of videos that I am trying to get as small as possible.

I’m looking for either some gui process, or perhaps a script I could put in a folder full of files and run to have them remux with all the attachments removed. I’ve been doing this manually but its, yeah, taking too much time.

Any help would be greatly appreciated. Thank you.

Welcome!

The relevant CLI option is --no-attachments that you have to add before the source file it should apply to. Therefore a very short shell script to remux all files into a sub-directory called remuxed, removing attachments would be:

for src in *.mkv ; do
  mkvmerge -o "remuxed/$src" --no-attachments "$src"
done

Convert that to any scripting language you want (Python, PowerShell, whatever).

1 Like

Thanks! I was able to get it working with powershell.

I guess for the sake of completeness I’ll include it here, as finding a way to batch remove attachments with mkvtoolnix was not getting any hits on search engines for dummies like me. So hopefully the next person will find this.

I don’t really know what I’m doing but the above info plus a bit of googling into powershell allowed me to cobble this together:

1.Create notepad file
2.Paste this (after installing mkvtoolnix of course)

$mkvmerge = "C:\Program Files\MKVToolNix\mkvmerge.exe"

$sourceDir = $PWD

Get-ChildItem -Path $sourceDir -Filter *.mkv | ForEach-Object {
    $inputFile = $_.FullName
    $outputFile = Join-Path $sourceDir ($_.BaseName + " (1).mkv")
    
    & $mkvmerge -o "$outputFile" --no-attachments "$inputFile"
}

3.Save. Change file format to .ps1.
4.Place it in the folder with your media files.
5.Right click > run with powershell.
6.Wait, and then done.

2 Likes

Just don’t run it twice in a row as the second run will also remux the files created by the first one (meaning it’ll create file (1).mkv during the first & file (1) (1).mkv during the second run etc.). It’d be a bit safer to use a different destination directory.

1 Like