SKwizard - Linux M4A Converter and file rename tool

Posted By Scott Klarr on Mar 07, 2008 at 1:53 am

As they say, you want something done right, you got to do it yourself! After my failed attempts to find a working tool to take care of 2 simple tasks on a large scale, I decided to write my own little program. Enter, SKwizard!

This shell script has two very useful abilities that are done recursively from any given starting point.

Features

File Renamer - This program will crawl your files/folders and not only replace all underscores with spaces, but will also capitalize the first letter of each word. I plan to add some more renaming options in the future but these two things were mainly what i was after.

M4A to MP3 Converter - This program will convert any M4A music files into MP3 - and retain the song tag information!

Usage

To use the program, all you have to do is run the command skwizard with the desired arguments (see below).

Convert m4a files to mp3 in linux

So say if you have your music collection at /storage/music/. You wanted to rename all files/folders and also convert any m4a files. Simply load up the command line and run skwizard -dfcr /storage/music/ - it will do its thing!

You can have it do any or all of the actions listed by themselves or together.

I ran this program against my 180gb music collection and am very happy with the results :)

View source code at: http://www.scottklarr.com/files/skwizard/skwizard

Installation

This script requires that you have LAME and FAAD2 installed in order to use the M4A to MP3 conversion. The file/folder renaming operations will work fine without these dependencies.

su cd /tmp wget http://www.scottklarr.com/files/skwizard/skwizard mv skwizard /bin/ chmod +x /bin/skwizard exit

Like I said above, I used this on my own music collection and it worked absolutely great (i did a lot of testing and triple checking before actually enabling the destructive commands). I am 99% sure it will work for you, but I have to say that I do not guarantee its performance. Use at your own risk.

This is my first shell script thats beyond just a couple lines, so there are probably better ways to do things, but I'm still new to it, so...

If you have any comments, suggestions, or ideas -- please let me know! This script is completely free to do with as you please. If you make any changes to it though, please send me a copy so i can see the improvements made!

Todo

  • See how reacts to permission denied.
  • Fix bug of renaming II, III to Ii, Iii.
  • Add more file renaming abilities with command line switches.

This post has the following tags:

Related Links

Last 5 Linkbacks

Comments (11)

Tmo - Aug 13, 2008

HELP!! I keep getting this error --- Unable to find correct AAC sound track in the MP4 file.

bsack - Jul 29, 2008

re: renaming as .M4a - i had the same problem initially, so went into the script and changed the two instances of
"grep '.m4a'"
to
"grep '.[Mm]4a'"

not the most elegant solution, but it got the script working. thanks!

Bill - Jul 01, 2008

When I tried it, all the extensions got changed to M4a. The grep command that looked for m4a wasn't matching. I added "-i" to make it ignore case and it is grinding through my files as I type. Thanks for the script!

GX - May 11, 2008

Hi

Thanks for the script. For some reason it would always show help no matter what so I had to put comments on the if for the help and then it worked.

richard d - Apr 13, 2008

I found an annoying fact about this script: it will capitalize names after special characters. So Antonín Dvo%u0159ák becomes AntoníN Dvo%u0159áK, Frédéric Chopin becomes FréDéRic Chopin, etc. This should get removed from the code.

Otherwise, wonderful little thing, I wanted to get rid of underscores and .m4a files and this did the trick.

Munra - Mar 11, 2008

Thanks. Sorry i should read the man lame.
Thanks again.

Scott Klarr - Mar 10, 2008

Unfortunately (for some odd reason), the LAME encoder will only accept the name of a genre if its included in a somewhat limited list they provide. Run "lame --genre-list" to see a list that genres are limited to.

Munra - Mar 09, 2008

Hi: again me.
Well i fund this, first i make a little change in you script (i don't know nothing about scripting i just see your script and make changes and wait to see what happend)
this was the change
=> your script:
faad -o - "$1" | lame --tt "$title" --ta "$artist" --tn "$track/$totaltracks" --tl "$album" $tg - "$newMp3Name"

=> the change
faad -o - "$1" | lame --tt "$title" --ta "$artist" --tn "$track/$totaltracks" --tl "$album" --tg "$genre" - "$newMp3Name"

So i delete $tg and put --tg "$genre", and works i have the genre of the mp3 file in Rhythmbox. But not with the first song, with another song that have the tag genre "Thecno" this is the info in terminal :

Motorway.m4a file info:
LC AAC 357.725 secs, 2 ch, 44100 Hz
title: Motorway
artist: Carl Cox
unknown: Various Artists
album: Carl Cox - F.A.C.T (Disk 2)
genre: Techno
track: 14
date: 1995

So when i try to convert the first song with the tag genre "Los Años Maravillosos", this is the info in terminal:

Tell it like it is.m4a file info:

LC AAC 163.007 secs, 2 ch, 44100 Hz

title: Tell it like it is
artist: Arron Neville
album: SuperHits 1967
genre: Los Años Maravillosos
track: 11

i have this message:

Unknown genre: 'Los Años Maravillosos'. Specify genre name or number.

I try with other directory and the same happend. This is the info of the other directory:

Somebody Save Me.m4a file info:

LC AAC 196.319 secs, 2 ch, 44100 Hz

title: Somebody Save Me
artist: Cinderella
unknown: Cinderella
writer: Tom Keifer
album: Night Songs
genre: Poser Rock
track: 7
date: 1986

in this is the message:
Unknown genre: 'Poser Rock'. Specify genre name or number.

Thanks again and I hope you give a answer.

I see that when i use you script without any change i still have the message with other mp3 file that have different genre, this is message

Unknown genre: '"Folk"'. Specify genre name or number.

So, with the genre '"Folk"' dont't work, but this time the message is little different have double quotes, this is:

Unknown genre: '"Folk"'. Specify genre name or number

But in Rhythmbox the genre in m4a is just Folk.

Thanks again and I hope you give a answer.

I going to see if i find why have problems with this genres, or mp3 files, probably are the file not the genre. Bye

P.D. I hope you understand me, because i have bad English and the addon "gtranslate" that i use for the words that i don't remember don't work in Firefox Beta 3.

Munra - Mar 09, 2008

Hi:
Thanks for you answer.
And the thing with the tag of genre?
Because i have this in the terminal:

LC AAC 163.007 secs, 2 ch, 44100 Hz

title: Tell it like it is
artist: Arron Neville
album: SuperHits 1967
genre: Los Años Maravillosos
track: 11

But when i import the file (the mp3) into Rhythmbox i don't have the genre, the Rhythmbox show (unknow) in genre. ( when i import the m4a Rhythmbox show me the genre, in this case "Los Años Maravillosos"). So, how i can do that the Rhythmbox show me the genre in the mp3 files.
Thanks for you script and your time.

Scott Klarr - Mar 08, 2008

Munra, thanks for letting me know. I'm having trouble figuring out how to make the for loop not split every space into a separate result. You'd think it would be straight forward but I'm not having any luck figuring it out.

An easy work around to this is to simply CD into '/path/to/music directory with space' yourself, and then run the script without a path (if you run it without a path specified, it will use the current path you are in)

So you would go:
$ cd "/path/to/"music directory with space"
$ skwizard -[dfcr]

Munra - Mar 08, 2008

Hi:
Thanks for you script, but when i try to convert a directory that have a name with space like this '/path/to/music/directory\ with\ space/'
i have this:
/path/to/music/directory is not a valid starting point!

So i use quotes in the path like this => /path/to/"music directory with space" but give me the same message=>

/path/to/music/directory is not a valid starting point!

So i change the name of the directory to => /path/to/music/directory
and works.
But it is rare because in the "directory" i have another directory with space and works, so my solution was cd into /path/to/"music directory with space" and run skwizard -cr.
i can't do works recursively and the tag of genre disappear in the process.
I don't know is this things are for the program or are for me that don't understand how to use the script.
I hope you give a answer.

Post Comment

Your Name
Email Address
Website URL
Comment

Your email address will not be visible to the public

page counter

Loading Ad