Script To Make And Tag Mp3 Files - AVS Forum
Forum Jump: 
 
Thread Tools
post #1 of 2 Old 01-10-2012, 05:33 PM - Thread Starter
AVS Special Member
 
waterhead's Avatar
 
Join Date: May 2007
Posts: 1,260
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 4 Post(s)
Liked: 12
I have been working on a script that will automatically transcode my wave files into mp3 files, tag them and as a bonus create a playlist for the files.

You will need these programs installed:

ffmpeg
id3ren
fapg

I am using the folder names and - to tag the mp3 file, by making variables out of the names.

This assumes you have your music library structured in a certain way. I use this structure:
///-.wav

An example:
/Rory Gallagher/Tattoo/01-Tattoo'd Lady.wav

I would like input how to improve it. The id3ren program was the hardest one to get to work properly. If you want to use that program alone, or alter what it is doing, I can help.

Thanks for trying.

EDIT (1/13/12): I found an easier way to deal with spaces in file names, and combined everything into one simple script:

Code:
#!/bin/bash

# This is a script to transcode wave audio files (.wav) to .mp3, using ffmpeg.
# It will also tag the .mp3 files, using the existing folder name and file name.
# As a bonus, it will also create a .pls playlist in the folder containing the mp3 files.
# It uses these programs, which you first must install:
#
# ffmpeg
# id3ren
# fapg
#
#
# This script will only work correctly if you have your music arranged in folders like this:
# ///-.wav
#
# An example:
# /Rory Gallagher/Tattoo/01-Tattoo'd Lady.wav
#
#
# Create two functions to make the $ALBUM and $ARTIST variables, and run them:

echo
function ALBUM {
ALBUM=`basename "$PWD"`
echo "Album = $ALBUM"
sleep 3s
}

ALBUM

# Go up one level in the directory, to get the name of the Artist:

cd ..

echo
function ARTIST {
ARTIST=`basename "$PWD"`
echo "Artist = $ARTIST"
sleep 3s
}

ARTIST
echo
echo

# Go back to the previous folder:

cd "$OLDPWD"

# Replace spaces with underscores:
# dirty hack to make spaces in file names work
oldifs=$IFS; #IFS= Internal Field Separator
IFS=_

# Convert wave files in current directory to mp3 files.
# Make a new folder mp3 using the name of the current folder,
# and move the mp3 files to that folder.

for i in *.wav; do mv "$i" `echo $i | tr ' ' '_'`; ffmpeg -i $i -ab 320k -acodec libmp3lame ${i%.wav}.mp3; mkdir "$ALBUM-mp3"; mv *.mp3 "$ALBUM-mp3"; done


cd "$ALBUM-mp3"

# Tag files using id3ren:

id3ren -tagonly -tagfromfilename -tagtemplate '%n-%s.mp3' -nocomment -noyear -album="$ALBUM" -genre=12  -artist="$ARTIST" *.mp3

# Make a playlist using fapg

fapg --format=pls --output="$ALBUM".pls "$PWD"

# Undo hack from above.
IFS=$oldifs;
waterhead is offline  
Sponsored Links
Advertisement
 
post #2 of 2 Old 01-13-2012, 04:20 PM - Thread Starter
AVS Special Member
 
waterhead's Avatar
 
Join Date: May 2007
Posts: 1,260
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 4 Post(s)
Liked: 12
I have revamped my script, and was able to put everything into one simple script. See the first post for the update.

I found a hack to deal with spaces in file and folder names. It temporarily alters the IFS (Internal Field Separator), then returns it to normal when done.
waterhead is offline  
Reply HTPC - Linux Chat

User Tag List

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off