Skip to content

Instantly share code, notes, and snippets.

@packerdl
Created March 26, 2022 13:28
Show Gist options
  • Save packerdl/006754f526f3dd265c0ca313206cd117 to your computer and use it in GitHub Desktop.
Save packerdl/006754f526f3dd265c0ca313206cd117 to your computer and use it in GitHub Desktop.
Recursively search for and verify flac files
#! /usr/bin/env bash
# Recursively searches for flac files in the supplied
# directory and checks them for errors.
shopt -s globstar
error_log="$(pwd)/errors.log"
green='\033[0;32m'
red='\033[0;31m'
yellow='\033[0;33m'
reset='\033[0m'
if [ -z "$1" ]; then
echo -e "${red}A starting folder is required${clear}"
exit 1
fi
if [ ! -d "$1" ]; then
echo -e "${red}The supplied folder is either not a folder or does not exist${clear}"
exit 1
fi
echo -e "Entering ${yellow}$1${clear}"
cd "$1"
for file in ./**/*.flac; do
if flac -wst "$file" 2> /dev/null; then
echo -e "${green}[OK] $file${clear}"
else
echo -e "${red}[!!] $file${clear}"
echo "$file" >> "$error_log"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment