Skip to content

Instantly share code, notes, and snippets.

@pope
Created May 1, 2013 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pope/5494029 to your computer and use it in GitHub Desktop.
Save pope/5494029 to your computer and use it in GitHub Desktop.
A simple script to rename the mp4s in a directory into something that Plex likes. YMMV.
for i in *.mp4; do
ffprobe "$i" 2>&1 | awk -v i="$i" '
BEGIN { FS=": " }
/title/ { title=$2 }
/artist/ { artist=$2 }
/track/ { sub(/\/12/,"",$2); track=$2 }
/album/ { sub(/^.*Pt\. /,"",$2); season=$2 }
END {
printf("mv \"%s\" \"%s - s%02de%02d - %s.mp4\"\n", i, artist, season, track, title)
}'
done | bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment