You can use inotify which is a folder monitoring software: it launch a command when a file is created .
Here, it will launch mp3gain . To set up :
- Install
sudo apt-get install inotify-tools incron mp3gain
- edit incron.allow
sudo gedit /etc/incron.allow
then add your username , save , you may
reboot (not sure but ...)
- Choose or create a folder where sound files will be copied and then normalized
(Here I create a new folder "normalize" in my home dir. but you may use existing folder be on your usb device,
something like /media/ipod/music)
mkdir ~/normalize
- Run
incrontab -e
and copy this line in the editor (replace 2 "username" with your login ) :
/home/username/normalize IN_CREATE /home/username/normalize.bash $@/$#
Save and close editor .
This set the monitored folder and the command executed when a file is created in (command is normalize.bash ).
(If you have problem with default editor , you can change it to pico (gedit don't work for me) : Run this before incrontab -e
:
export EDITOR=pico
)
- Create a new file normalize.bash containing this :
#!/bin/bash
PATH1=/home/username/normalize
echo "***********************************************************" >> ~/normalize.log
date >> ~/normalize.log
#get extension to exit on TMP files
filename=$(basename "$1")
extension="${filename##*.}"
if [[ "$extension" = "TMP" ]]
then
echo TMP exit>> ~/normalize.log
exit
fi
# do normalize
/usr/bin/mp3gain -c -r "$1" >> ~/normalize.log
#END
In second line change PATH1 to the previously created/existing folder.
Save as normalize.bash in your home.
Now, when a file is created in the folder "normalize", mp3gain will run
(actions are logged in normalized.log file in home dir)