You are not logged in.

#1 2010-02-05 19:47:43

grassman
Member
From: NYC
Registered: 2010-01-25
Posts: 2

Bash: iterating directories for mp3gain

I'm still completely new to Bash. I'm looking to pass all the files under one given directory to mp3gain, but I want to scan them in sets of albums to use with the album tag -a, so I need a way to iterate over the individual sucdirectories, then perform mp3gain -a *.mp3 on each album folder individually, separate from the other subdirectories.

The directory is set up in the format:

~/music/artist/album/song.mp3

Could somebody point me in the right direction?

Offline

#2 2010-02-05 19:59:06

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: Bash: iterating directories for mp3gain

find $HOME/music/artist -maxdepth 1 -type d | while read dir; do
  mp3gain -a "$dir/"*.mp3
done

Offline

#3 2010-02-06 12:50:56

draugdel
Member
Registered: 2008-08-12
Posts: 44

Re: Bash: iterating directories for mp3gain

#!/bin/bash

for artist in *; do
    echo "$artist"
    if [ -d "$artist" ]; then

        cd "$artist"
        for album in *; do
            if [ -d "$album" ]; then
                mp3gain -a -k -d 2.0 "$album"/*;
            fi
        done

        cd ..
    fi
done

To be executed in the top level directory of your collection (~/music).

Offline

Board footer

Powered by FluxBB