I am working on a script that reads all folders inside a Movie folder and outputs the information for each video in a file.
The current one I have is this:
movies=0
rm movielist
for dir in Movies/*
do
(cd "$dir" && pwd|cut -d \/ -f5|tr -s '\n' ', ' >> ../../movielist &&
>> ../../movielist )
echo "Movie $movies - $dir ADDED!"
let movies=movies+1
done
rm moviefinal
cat movielist | while read MovieName;
do
echo "$MovieName" | cut -d ',' -f2 | cut -d 'x' -f2 | sort | uniq | while read MovieRes;
do
case $MovieRes in
[461-660]*)
echo "$MovieName,480p" >> moviefinal
;;
[661-890]*)
echo "$MovieName,720p" >> moviefinal
;;
[891-1200]*)
echo "$MovieName,1080p" >> moviefinal
;;
*)
echo "$MovieName,DVD" >> moviefinal
;;
esac
done
done
Which reads from the Movies folder each movie (eg: Movies/The Matrix/Matrix.mkv) and sends it to a file called moviex inside the Movies folder. The info inside the file is something like this:
The Matrix, 1920x1080, MKV
The Matrix 2, 1280x720, AVI
....
What I want to add now is a way to read the Height and Width (Which are the SourceImageHeight and SourceImageWidth with exiftool) and do a CASE or IF where, if the height is X and width is Z then add to the output file another variable which is the quality (ie: 720p, 1080p, DVD...). The above would look something like this:
The Matrix, 1920x1080, MKV, 1080p
The Matrix 2, 1280x720, AVI, 720p
UPDATE - The script is now showing the Quality (720p, 1080p) but the CASE part is wrong. It sometimes grabs for example a 720 video and gives it a DVD quaility, when in fact, in the script I explicitly said 720.