Skip to content

Instantly share code, notes, and snippets.

@moba
Created December 13, 2019 21:49
Show Gist options
  • Save moba/71ff596ff91e81172a5086eb30c06e72 to your computer and use it in GitHub Desktop.
Save moba/71ff596ff91e81172a5086eb30c06e72 to your computer and use it in GitHub Desktop.
scans one mp3 per directory and prints files with low bitrate
#!/bin/bash
scanfile ()
{
FILE="${1//[$'\n']}" # drop newline from argument
BITRATE=$(/usr/bin/mediainfo "$FILE" --Output=JSON | jq '.media.track[0].OverallBitRate')
BITRATE="${BITRATE//[$'\"']}" # remove "
if [[ $BITRATE -lt "130000" ]]; then
echo $BITRATE " " $FILE
fi
}
scan ()
{
export -f scanfile
find "$1" -name '*.mp3' -type f -maxdepth 1 | head -1 | xargs -0 -P4 -I {} bash -c 'scanfile "$@"' _ {}
}
export -f scan scanfile
find . -type d -print0 | xargs -0 -P4 -I {} bash -c 'scan "$@"' _ {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment