Created
March 23, 2020 03:08
-
-
Save scrathe/0bedf625916df1a0d070c053c284017d to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# what is this? identify movies that are named (movie title), THE (year) and rename to (THE movie title) (year) | |
OLDIFS="$IFS" | |
IFS=$'\n' | |
targetDirectories=$(find . -maxdepth 1 -type d -regextype "posix-extended" -regex '.*\,\s(The|the)\s.*' -print | cut -d/ -f 2) | |
for dir in $targetDirectories; do | |
regexThe="(.*)\,\s(The|the)\s(\(.*\))" | |
if [[ $dir =~ $regexThe ]]; then | |
movieTitle=${BASH_REMATCH[1]} | |
movieThe=${BASH_REMATCH[2]} | |
movieYear=${BASH_REMATCH[3]} | |
# echo "mv $dir -> $movieThe $movieTitle $movieYear" | |
mv "$dir" "$movieThe $movieTitle $movieYear" | |
fi | |
done | |
IFS="$OLDIFS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment