Skip to content

Instantly share code, notes, and snippets.

@flyser
Forked from powerswitch/makemkv.sh
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyser/9692824 to your computer and use it in GitHub Desktop.
Save flyser/9692824 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [[ "x$1" = "x" ]]; then
echo "Usage:"
echo " $0 <searchpath>"
exit 1
fi
find "$(readlink -f "$1")" -type d -name STREAM | while read M ; do
cd "$M"
# Determine name of the Movie
NAME="$(echo "$M" | sed "s_.*/\([^/]*\)/STREAM_\1_")"
# Find all parts that will be merged
FILES="$(echo *.m2ts | sed "s_ \([^ ]*\)_ +\1_g")"
# Define output filename
OUTPUT="../$NAME.mkv"
# Ignore preexisting files
if [[ -e "$OUTPUT" ]]; then
echo "File '$OUTPUT' exists. ignoring ..."
continue
fi
# Print what would be executed, uncomment the second line to execute
echo "mkvmerge $FILES -o $OUTPUT"
#mkvmerge $FILES -o "$OUTPUT"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment