#!/bin/bash for file in `find . | grep ".mp4$"`; do newname=`basename -s .mp4 $file` newdirname=`dirname $file` output=$newdirname"/"$newname"_o.mp4" tt=`ffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 $file` echo $tt | awk -F'[ =]+' #'{print $2,$4}' HandBrakeCLI -i $file -o $output -O -e x264 -q 22 -w $2 -l $4 -B 48 #HandBrakeCLI -i $file -o $output -O -e x264 -q 22 -w 1280 -l 720 -B 48 #mv $output $file done