#!/usr/bin/bash
# check arguments passed and set defaults if needed
# No argument given?
if [ -z "$1" ]; then
printf "\nUsage:\n\n pass a starting point and min data rate in kbps and min size like /media/gessel/datas/Downloads/ 100 10 \n\n"
exit 1
fi
if [ -z "$2" ]; then
printf "\nUsage:\n\n returning files with data rate greater than default max of 100 kbps \n\n"
maxr=100
else
maxr=$2
echo -e "\n\n returning files with dara rate greater than " $maxr " kbps \n\n"
fi
if [ -z "$3" ]; then
printf "\nUsage:\n\n returning files with file size greater than default max of 100 MB \n\n"
maxs=10
else
maxs=$3
echo -e "\n\n returning files with dara rate greater than " $maxs " MB \n\n"
fi
# multipliers to get to human readable values
msec="1000"
kilo="1024"
echo -e "file path \t rate kbps \t size MB"
# search for files with the extensions enumerated below
# edit this list to your needs (e.g. -iname \*.mp3 or whatever
# the -o means "or", -iname (vs -name) means case independent so
# it will find .MKV and .mkv.
# then pass each file found to check if the data rate is
# above the min rate of concern and then if the files size is
# above the min size of concern, and if so, print the result
find "$1" -type f \( -iname \*.avi -o -iname \*.mkv -o -iname \*.mp4 -o -iname \*.wmv \) -print0 | while read -rd $'\0' file
do
size="$(wc -c "$file" | awk '{print $1}')"
duration="$(mediainfo --Inform="Video;%Duration%" "$file")"
seconds=$(bc -l <<<"${duration}/${msec}")
sizek=$(bc -l <<<"scale=1; ${size}/${kilo}")
sizem=$(bc -l <<<"scale=1; ${sizek}/${kilo}")
rate=$(bc -l <<<"scale=1; ${sizek}/${seconds}")
if (( $(bc <<<"$rate > $maxr") )); then
if (( $(bc <<<"$sizem > $maxs") )); then
echo -e $file "\t" $rate "\t" $sizem
fi
fi
done
Desktop (please complete the following information):
Describe the bug unexpected italization in code highlighting
WordPress Editing Mode Which WordPress editing mode you're using ?
Frontend or Backend Issue
Frontend
To Reproduce
Format the code (below) as bash.
Expected behavior more consistent font use - in particular less apparently random italicization.
Screenshots
Example code
https://blackrosetech.com/gessel/2022/09/02/smol-bash-script-for-finding-oversize-media-files
Desktop (please complete the following information):