How can I filter and sort videos by orientation (portrait or landscape)?

After testing @CJK's answer, here's what I came up:

#!/bin/bash
shopt -s nullglob

for f in *.{mp4,MP4,mov,MOV,m4v,M4V}
    do 
        height=`mdls -raw -name  kMDItemPixelHeight "$f"`
        width=`mdls -raw -name  kMDItemPixelWidth "$f"`
        mkdir -p "${height}x${width}"
        mv "$f" "${height}x${width}"/
        
        printf "File: $f\n"     
        printf "> Dimensions: $height x $width \n\n"
    done

printf "All done! \n"

This will grab the height and width of each video type in a specific folder, and then sort it into its appropriate folder. With a bit more scripting, you could then sort the folders into portrait/landscape folders by comparing height vs. width.