Last active
March 18, 2020 03:44
-
-
Save JustAPerson/2f2bc1171e5446494c6ecc27fbca620f to your computer and use it in GitHub Desktop.
jellyfin renumbering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match($0,/([[:digit:]]+).*(\..+)/,a) { printf "%s %s%s%s\n", ENVIRON["title"], ENVIRON["EPPREFIX"], a[1], a[2] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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