Skip to content

Instantly share code, notes, and snippets.

@kescherCode
Created June 18, 2019 10:42
Show Gist options
  • Save kescherCode/11bf1b3ef5aa62de69f13243c4949a9a to your computer and use it in GitHub Desktop.
Save kescherCode/11bf1b3ef5aa62de69f13243c4949a9a to your computer and use it in GitHub Desktop.
List 24-bit and 16-bit FLACs in current directory.
#!/usr/bin/env bash
# Check if mediainfo is installed. That tool is needed to parse the bit depth of flac files in your current directory.
if ! `hash mediainfo &>/dev/null`; then
echo "Install mediainfo prior to using this script!"
exit 1;
fi
bit24="24-bit:\n"
bit16="16-bit:\n"
for f in *.flac; do
# --Inform="Audio;%BitDepth%" parses the depth, and nothing else.
depth=`mediainfo --Inform="Audio;%BitDepth%" "$f"`
if [ "$depth" == "16" ]; then
bit16="${bit16}${f}\n"
elif [ "$depth" == "24" ]; then
bit24="${bit24}${f}\n"
else
# This really shouldn't happen. If it does, well, check the bit depth of that file, and add another variable and case.
echo "unknown bit depth for file $f!"
fi
done
echo -e $bit24
echo -e $bit16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment