Skip to content

Instantly share code, notes, and snippets.

@allenhsu
Last active May 12, 2018 05:10
Show Gist options
  • Save allenhsu/53c9a305f99e66c46c8bbfe3e79ac2c2 to your computer and use it in GitHub Desktop.
Save allenhsu/53c9a305f99e66c46c8bbfe3e79ac2c2 to your computer and use it in GitHub Desktop.
#!/bin/bash
#brew install mediainfo first
#chmod a+x check_audio_channels.sh for permission
#run ./check_audio_channels.sh dir_name to check
function check_dir() {
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
check_dir $1"/"$file
else
check_file $1"/"$file
fi
done
}
function check_file() {
if [[ $1 == *.mp4 ]]
then
if mediainfo $1 | grep Channel\(s\) | grep -qc '2 channels'
then
echo "File: "$1" # PASS"
else
echo "File: "$1" # FAIL, audio format is wrong!"
fi
fi
}
check_dir $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment