simply run it in a directory with anime files
bash ./anime-org
or
chmod +x ./anime-org
./anime-org
#!/bin/bash | |
command -v "detox" >/dev/null || { | |
echo -e "\e[33;1m detox command not found" | |
echo -e "\e[0m https://github.com/dharple/detox \n" | |
echo -e "\e[36m sudo pacman -S detox \e[0m\n" | |
exit 1 | |
} | |
:> /tmp/anime-org_pre | |
:> /tmp/anime-org_pos | |
[ "$1" == "--dry" ] && DRY=1 | |
((DRY)) || detox -r . | |
commands=' | |
s/^.*/\L&/; | |
s/v[0-9]{1}//g; | |
s/(480|540|720|1080).*//; | |
s/s[0-9]{2}e[0-9]{2}//g; | |
s/[0-9]{1,2}//g; | |
s/(puyasubs|commie|deadfish|horriblesubs|subsplease|erai-raws|ember|sakuracircle|mkv|end|\.|--|__|,|#)//g; | |
s/-_|_-/-/g; | |
s/^[-_]|^e-|[-_]$//g; | |
s/[-_]+$//g; | |
' | |
count=0 | |
while read -r file; do | |
file="${file#./*}" | |
read -r norm < <(sed -E "$commands" <<<"$file") | |
echo "$file" >> /tmp/anime-org_pre | |
echo "$norm" >> /tmp/anime-org_pos | |
echo | |
echo -e "\e[32m :: $((++count))" | |
echo -e "\e[33m := $file" | |
echo -e "\e[36m :> $norm" | |
[ -z "$norm" ] && continue | |
((DRY)) || mkdir -p "$norm" &>/dev/null || : | |
((DRY)) || mv "$file" "${norm}/${file}" | |
done < <(find . -maxdepth 1 \ | |
-type f \ | |
-name '*.mkv' \ | |
-or \ | |
-name '*.mp4') | |
# vim:ft=bash |