This script I use will work (FLAC files only) IF you have your files organized by Artist/Album (where each album has its own folder) (not sure how else it could/should be organized)
This script will walk the directory entered in the FIRST line. My files are in ~/Music/FLAC, so starting there will process all FLAC files.
If you want to use this, test on one Album (or Artist) first:
Code:
#!/bin/bash StartDir=$HOME/Music/FLAC # No trailing slash! count=0 function walk_tree { local directory="$1" local i for i in "$directory"/* do if [ -d "$i" ]; then # Process directory and then walk-down ls "$i/"*.flac | grep -i -q -s ".flac$" # Does directory contain FLAC files? if [ $? -eq 0 ] ; then echo "Adding replay gain tags to:" for j in "$i/"*.flac do echo "$j" let count++ done /usr/local/bin/metaflac --preserve-modtime --add-replay-gain "$i/"*.flac echo "$i done!" # echo directory that we're in echo $count files processed. fi walk_tree "$i" # DO NOT COMMENT OUT THIS LINE!! else continue # replace continue with command to process individual file "$i" (i.e. echo "$i") fi done } # Process FLAC files in starting directory cd "$StartDir" ls *.flac | grep -i -q -s ".flac$" # Does directory contain FLAC files? if [ $? -eq 0 ] ; then echo "Adding replay gain tags to:" for j in *.flac do echo "$j" let count++ done /usr/local/bin/metaflac --preserve-modtime --add-replay-gain *.flac echo "$StartDir done!" # echo directory that we're in echo $count files processed. fi # Now walk down tree in this directory walk_tree "$StartDir"
Leave a comment: