#! /bin/bash
# sets the title of all mkv videos to the filename without extension
-for f in *.mkv; do
- t=${f%.mkv}
- mkvpropedit --set title="$t" "$f"
+dir=${1-.}
+for f in "$dir"/*; do
+ case "$f" in
+ *.mkv) ext=mkv ;;
+ *.webm) ext=webm ;;
+ *) continue ;;
+ esac
+ t=$(basename "$f" "$ext")
+ t=${t%.*}
+ # remove also (2013){1080p}[en] stuff
+ t=${t% (*)\{*\}*}
+ echo "Set title: $t"
+ mkvpropedit --set title="$t" "$f" > /dev/null
done