lsvideoheight_core() { # $1 = height # $2 = current file name mediainfo_result=$(mediainfo "$2" |egrep "(Complete name|Height.*: $1)"); mediainfo_height=$(echo "$mediainfo_result" | tail -n 1 ); if ( [[ $mediainfo_height == "Height"*": $1 pixels" ]] ); # if video height matches; no quotation marks to remove excessive spaces then { echo "$mediainfo_result" | head -n 1 | grep "$2" |sed -r "s/^.*: //g"; }; fi # remove everything except the file path } lsvideoheight() { # Iterate though multiple files. # Two separate loops because arguments containing file names with spaces can not be passed through a variable containing either all files in the current directory or all specified files, because they would be stringified into one argument. argument_count=0; # for loop skips over first argument with video height if [ ! "$2" ]; then # no file specified = list all in current directory for current_item in "" *; # blank dummy string so files start at second argument; not using "${@:2}" for sh compatibility do { if [ $argument_count -ge 1 ] && [ -f "$current_item" ]; then lsvideoheight_core "$1" "$current_item"; fi; # files only, exclude directories argument_count=$(( argument_count + 1 )); } done else # specified file names and directories for current_item in "$@"; do { if (test $argument_count -ge 1 ); then # directory handler: if current item is a directory if [ -d "$current_item" ]; then for subfile in "$current_item"/*; do lsvideoheight_core "$1" "$subfile"; done else lsvideoheight_core "$1" "$current_item"; fi; fi; argument_count=$(( argument_count + 1 )); } done fi } ls4320p() { lsvideoheight "2 160" "$@"; } # 8K ls2160p() { lsvideoheight "2 160" "$@"; } # 4K ls1440p() { lsvideoheight "1 440" "$@"; } # QHD / WQHD ls1080p() { lsvideoheight "1 080" "$@"; } # Full HD ls720p() { lsvideoheight "720" "$@"; } # HD ls480p() { lsvideoheight "480" "$@"; } # HQ ("high quality") / SD ("standard definition") # aliases alias ls8K=ls4320p; alias ls4K=ls2160p; alias lsUHD=ls2160p; alias lsQHD=ls1440p; alias lsFHD=ls1080p; alias lsHD=ls720p;