Created
December 13, 2019 21:49
-
-
Save moba/71ff596ff91e81172a5086eb30c06e72 to your computer and use it in GitHub Desktop.
scans one mp3 per directory and prints files with low bitrate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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