[dimension-tag-video-files] one-liner to add resolutions of video files to their filenames (only prints commands, i.e. dryrun - pipe to execute) #bash #ffmpeg #video
find . -type f -regex ".*\.\(avi\|mp4\|mkv\)" -exec sh -c \
'ffprobe -v quiet -print_format flat -show_format -show_streams "$0" | \
grep "\\.height\|\\.width\|\\.filename" | tr "\n" " " && echo "\n"' {} \; | \
sed 's/.*width=\([0-9]*\).*height=\([0-9]*\).*filename=".\/\(.*\/\)\?\(.*\)".*/mv "\3\4" "\3[\1x\2] \4"/' | \
sed "/^$/d"