Skip to content

Instantly share code, notes, and snippets.

@JustAPerson
Last active March 18, 2020 03:44
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 JustAPerson/2f2bc1171e5446494c6ecc27fbca620f to your computer and use it in GitHub Desktop.
Save JustAPerson/2f2bc1171e5446494c6ecc27fbca620f to your computer and use it in GitHub Desktop.
jellyfin renumbering
match($0,/([[:digit:]]+).*(\..+)/,a) { printf "%s %s%s%s\n", ENVIRON["title"], ENVIRON["EPPREFIX"], a[1], a[2] }
if [[ $# != 1 ]]; then
echo 'usage: renumber.sh <title>'
echo
echo You can use the EPPREFIX environ variable to set a prefix directly
echo before the episode number. Consider the following
echo
echo EPPREFIX="s1e" ./renumber "The Title"
echo
echo This will create symbolic links to each episode where the new
echo file names follow the pattern:
echo
echo ./The Title s1e1.mkv
echo ./The Title s1e2.mkv
echo ...
echo
exit 1
fi
gawkscript=$(dirname $(realpath $0))/renumber.awk
export title=$1
for file in ./*; do
old=$(realpath "$file")
new=$(echo "$file" | gawk -f $gawkscript)
#echo file $file
#echo old $old
#echo new $new
ln -s "$old" "$new"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment