22-08-2024

This commit is contained in:
2024-08-22 08:44:15 +02:00
parent 4675acdd0d
commit aaf3776e62
20 changed files with 782 additions and 4 deletions

67
rename_series.sh Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env bash
italic="\033[3m"
underline="\033[4m"
ita_under="\033[3;4m"
bgd="\033[1;4;31m"
red="\033[1;31m"
green="\033[1;32m"
yellow="\033[1;33m"
bold="\033[1m"
box="\033[1;41m"
reset="\033[0m"
shopt -s globstar
SRC="$HOME/Downloads"
DEST="$HOME/Movies"
DEST_EXT=mp4
#HANDBRAKE_CLI=HandBrakeCLI
PRESET="Apple 720p30 Surround"
MAXSIZE=30000000
REGEX="([sS]([0-9]{2,}|[X]{2,})[eE]([0-9]{2,}|[Y]{2,}))"
#REGEX2="[0-9]{4}"
REGEX2="2[0-9]{3}"
for FILE in "${SRC}"/**/*.{mkv,avi,mp4,m4v}
do
echo "$FILE"
filename=$(basename "$FILE")
#echo "$filename" # Arctic.Circle.S01E02.iNTERNAL.MULTi.720p.WEB.H264-CiELOS.mkv
extension=${filename##*.}
#echo "$extension" # mkv
filename=${filename%.*} # sans extension
#echo "$filename" # Arctic.Circle.S01E02.iNTERNAL.MULTi.720p.WEB.H264-CiELOS
# Get file size
FILESIZE=$(stat -c%s "$FILE")
if (( FILESIZE > MAXSIZE )); then
if [[ $filename =~ $REGEX ]]; then
MATCH="${BASH_REMATCH[1]}"
e=$(echo ${filename%$MATCH*} | sed 's/\./\ /g' | xargs)
new_name="$e - $MATCH.$DEST_EXT"
echo "$new_name"
elif [[ $filename =~ $REGEX2 ]]; then
MATCH2="${BASH_REMATCH[0]}"
e=$(echo ${filename%$MATCH2*} | sed 's/\./\ /g' | xargs)
new_name="$e ($MATCH2).$DEST_EXT"
echo "$new_name"
else
echo "Could not find SXXEYY pattern in new format"
echo " "
continue
fi
echo "--------------"
fi
done