Created
July 3, 2019 04:00
-
-
Save luckylittle/bec98791c037d0837333ef89eea22f5d to your computer and use it in GitHub Desktop.
Convert all MP4s in a folder to MKVs using MKVMerge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requires: mkvmerge | |
for RH in *; do mkvmerge ${RH} -o $(basename -s .mp4 ${RH}).mkv; done; echo 'Done!' | |
# rm *.mp4 |
Alias in .bashrc
or .zshrc
:
alias convert2mkv="echo 'Converting MP4 to MKV in ~/Downloads/...'; find ~/Downloads -type f -name \"*.mp4\" -exec sh -c 'mkvmerge -o ~/Downloads/\$(basename "{}" .mp4).mkv {}' \;"
Alias also with folders creation:
alias convert2mkv="echo 'Converting MP4 to MKV in ~/Downloads/...'; find ~/Downloads -type f -name \"*.mp4\" -exec sh -c 'mkvmerge -o ~/Downloads/\$(basename "{}" .mp4).mkv {} ; mkdir -p ~/Downloads/\$(basename "{}" .mp4)' \;"
To convert all video/MP2T (*.ts
):
find . -type f -iname "*.ts" -execdir sh -c 'mkvmerge {} -o $(basename {} .ts).mkv' \;
Merge one *.mp4
and one *.m4a
inside each directory into a *.mkv
:
find . -name '*.mp4' -execdir sh -c 'mkvmerge -o "$(basename "{}" .mp4)".mkv {} "$(basename "{}" .mp4)".m4a' \;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One-liner that converts all
*.mp4
in~/Downloads
to*.mkv
usingmkvmerge
: