Skip to content

Instantly share code, notes, and snippets.

@walac
Last active May 28, 2016 02:25
Show Gist options
  • Save walac/4518306 to your computer and use it in GitHub Desktop.
Save walac/4518306 to your computer and use it in GitHub Desktop.
A simple script to make the .avi and .srt file names of my favorite series equal.
#!/bin/bash
if [ $# -gt 0 ]; then
basepath="$1"
else
basepath=
fi
for i in "${basepath}"*.mkv; do
e=$(echo "${basepath}"$i | sed -e 's/.*[Ss][0-9]\+[Ee]\([0-9]\+\).*/\1/')
x=$(ls -1 "${basepath}"*[Ss][0-9]*[Ee]$e*.srt)
mv "$i" "${x%%.srt}.mkv"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment