 |
hymn Hear Your Music aNywhere
|
| View previous topic :: View next topic |
| Author |
Message |
man on street Guest
|
Posted: Mon Jul 12, 2004 8:45 pm Post subject: m4p to mp3 (with ID3 tags!) |
|
|
I wrote this script because I needed to move music from my iPod to my iRiver. I understand dbPowerAmp + Hymn can do it, but I wanted one smooth step to do all my music. Also, dbPowerAmp messes up some of the tagging I found.
Of course I could not do it without hymn. Just put this script in any directory with hymn, faad, and lame. Drag any combination of files and/or directories onto the script. It will automatically recursively traverse every directory looking for .m4p files. It will then copy them to a working directory. It decrypts them using hymn, then decodes them using faad. Next it grabs the id3 tags using faad, and encodes to mp3 using lame (and the tags it just grabbed).
The output is written to the decoded directory. All subdirectories are named the source file's parent folder name. In English: ITunes downloads music in the form of ...\iTunes Music\Artist\Album\01 Track.m4p. If you were to drag your iTunes Music folder onto the script, you would end up with all of your protected aac files encoded and tagged under ...decoded\Artist\01 Track.mp3
Have fun! Lemme know if you have any issues...
BTW - I wrote this in VBScript so it would be open souce and could be run by all windows users. I do prefer Perl, but not everyone has it installed.
| Code: |
'coded by man on street
Set oFs = CreateObject ("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")
Set id3Options = CreateObject("Scripting.Dictionary")
binDir = oFs.GetFile(WScript.ScriptFullName).ParentFolder & "\"
workingDir = binDir & "working\"
decodedDir = binDir & "decoded\"
id3Options.Add "title", "--tt"
id3Options.Add "artist", "--ta"
id3Options.Add "album", "--tl"
id3Options.Add "date", "--ty"
id3Options.Add "track", "--tn"
id3Options.Add "genre", "--tg"
makeDirectory(workingDir)
makeDirectory(decodedDir)
For Each arg in WScript.Arguments
walkArguments(arg)
Next
removeDirectory(workingDir)
Sub convertFile(fileName)
Set protectedFile = oFs.GetFile(fileName)
albumName = protectedFile.ParentFolder.Name
albumDir = decodedDir & albumName & "\"
makeDirectory(albumDir)
protectedFile.Copy(workingDir)
trackName = oFs.GetBaseName(protectedFile)
return1 = oShell.Run(quote(binDir & "hymn") & " " & quote(workingDir & trackName & ".m4p"), 1, TRUE)
return2 = oShell.Run(quote(binDir & "faad") & " " & quote(workingDir & trackName & ".m4a"), 1, TRUE)
Set LaunchedApp = oShell.Exec(quote(binDir & "faad") & " -i " & quote(workingDir & trackName & ".m4a"))
tagInfo = LaunchedApp.StdErr.ReadAll
For Each tag in id3Options.Keys
tagSwitches = tagSwitches & " " & id3Options.Item(tag) & " " & quote(getTag(tag, tagInfo))
Next
return3 = oShell.Run(quote(binDir & "lame") & tagSwitches & " " & quote(workingDir & trackName & ".wav") & " " & quote(albumDir & trackName & ".mp3"), 1, TRUE)
End Sub
Sub walkArguments(arg)
If oFs.FolderExists(arg) Then
Set thisDir = oFs.GetFolder(arg)
Set subDirs = thisDir.SubFolders
Set theseFiles = thisDir.Files
If subDirs.Count > 0 Then
For Each dirName in subDirs
walkArguments(dirName)
Next
End If
For Each fileName in theseFiles
walkArguments(fileName)
Next
ElseIf oFs.FileExists(arg) Then
If oFs.GetExtensionName(arg) = "m4p" Then
convertFile(arg)
End If
End If
End Sub
Sub makeDirectory(dirName)
If Not oFs.FolderExists(dirName) Then
oFs.CreateFolder(dirName)
End If
End Sub
Sub removeDirectory(dirName)
If oFs.FolderExists(dirName) Then
oFs.GetFolder(dirName).Delete
End If
End Sub
Function quote(myString)
quote = Chr(34) & myString & Chr(34)
End Function
Function getTag(frameName, tagString)
Set oRegEx = New RegExp
oRegEx.Pattern = frameName & ".+\n"
frameNameAndValue = oRegEx.Execute(tagString).Item(0).Value
frameValue = Mid(frameNameAndValue, InStr(frameNameAndValue, ":") + 2)
getTag = Left(frameValue, Len(frameValue) - 2) 'Strip CR/LF
End Function
|
|
|
| Back to top |
|
 |
guest Guest
|
Posted: Thu Jul 15, 2004 6:57 am Post subject: |
|
|
| for the less technically inclined, how exactly would one execute this in windows? I also have an IRiver! its better than ipod imo, but I need a way to transfer! thnx |
|
| Back to top |
|
 |
man on street Guest
|
Posted: Thu Jul 15, 2004 1:38 pm Post subject: re: less technically inclined |
|
|
1) Copy the green stuff
2) Paste into a new file (notepad is fine)
3) SaveAs 'convert.vbs' (or anything you want.vbs)
4) Download the faad2 win32 binary from:
http://pessoal.onda.com.br/rjamorim/faad.zip
...or you could download the source from http://www.audiocoding.com and compile it yourself
5) Download the lame win32 binary from:
http://www.rarewares.org/files/mp3/lame3.96.zip
...once again you could compile from source code from http://sourceforge.net/projects/lame/
6) Of course you need the hymn win32 binary. I hope you know where to find it
7) Plase convert.vbs, faad.exe, and lame.exe all in a directory somewhere.
8] (gotta trick the smiley converter) Follow the instructions in my previous post
BTW - error correction. I previously said that files would be decoded into ...decoded\Artist\01 Track.mp3 but it really goes into ...decoded\Album\01 Track.mp3
Let me know how you make out. |
|
| Back to top |
|
 |
guest Guest
|
Posted: Thu Jul 15, 2004 4:58 pm Post subject: |
|
|
thanks for the reply!
I finally got hymn to work for me however, and I think its the easiet method I seen.
just drag/drop the files to convert onto hymn (no cmd line crud)
and then convert to desired format with that dBpower AMP
now I feel bad that you wrote all the above out, but im sure someone will find it most helpful
thanks |
|
| Back to top |
|
 |
man on street Guest
|
Posted: Fri Jul 16, 2004 1:36 pm Post subject: dbPowerAmp |
|
|
Yup, dbPowerAmp will do the trick; however, I was not satisfied with that option. It required too much work. You have to drag your m4p's onto hymn.exe artist at a time (or copy all your m4p's artist at a time into a working directory). Then you have to load the decrypted m4a's into dpPowerAmp for conversion. And when you done, you have to reorganize all the music back into directories.
Precisely the reason why I wrote this script. Drag, drop, done.  |
|
| Back to top |
|
 |
Wardy Guest
|
Posted: Thu Aug 05, 2004 1:48 pm Post subject: Man on Street is the Man!!! |
|
|
Hey Man on Street. I'm amazed how well your script works. I'm sure some may refer to you as a genius. Thank you so much for taking the time to exercise your knowledge, and then on top of that... Sharing it with the world. I have successfully used the instruction from your post & will continue to use it... I meant what I said in the subject line. Thank you very much.
Kindest regards,
Wardy from SoCal |
|
| Back to top |
|
 |
oldguy Guest
|
Posted: Fri Aug 13, 2004 11:16 pm Post subject: Empty folders while converting |
|
|
hi folks - I'm trying to do what man in the street has shared, but I end up with itunes folders in the "decoded" folder which are empty -- can anyone tell me what I am doing wrong? I'm running windows XP == do I need to reload hymn or get rid of other convet scripts?
Thank you. |
|
| Back to top |
|
 |
manonstreet Guest
|
Posted: Mon Aug 16, 2004 2:01 am Post subject: what's the problem? |
|
|
oldguy:
what exactly are you doing? you simply need those 3 files in a directory. Then drag your iTunes Music Folder onto the convert.vbs. Now the script will search all sub directories of the directory you just dragged onto it for filenames with the extension of .m4p. Then it will convert it and put it the decoded folder. |
|
| Back to top |
|
 |
cher45 Guest
|
Posted: Mon Aug 16, 2004 3:08 am Post subject: |
|
|
| Wow,This works great!! I am so glad to find your script.I had tried hymn a few months ago on XP but could never quite figure it out.I just decoded my entire iTunes folder in less than 20 minutes.Thank you much! |
|
| Back to top |
|
 |
old guy Guest
|
Posted: Mon Aug 16, 2004 3:34 pm Post subject: to manonstreet |
|
|
thanks for responding -- I'm doing eveything you say and I'm still ending up with either an empty folder called "itunes" (in the decoded folder) or it creates a bunch of artist folders but they are empty too.
any questions or ideas? |
|
| Back to top |
|
 |
old guy Guest
|
Posted: Mon Aug 16, 2004 3:41 pm Post subject: more |
|
|
I even show a "working folder" while the songs are converting and when I click on it I see where every m4p has a corresponding mpa - -BUT, this folder disappears when the converting is done and I end up with nothing in the decided folder --
while converting, I get a bunch of dos boxes it looks like, but my computer is processing too fast for me to read what is in them. |
|
| Back to top |
|
 |
Sylvia Guest
|
Posted: Tue Aug 17, 2004 3:45 pm Post subject: Thanks |
|
|
man on street,
thanks for the awesome code!! it worked great!  |
|
| Back to top |
|
 |
man on street Guest
|
Posted: Tue Aug 17, 2004 4:55 pm Post subject: |
|
|
everyone:
I'm glad it's working out for you
oldguy:
Looks like the script is copying the the files to the working directory, and hymn is sucessfully decoding them. The issue is either with faad or with lame. Do you ever see any .wav files in the working directory? If not, your problem is with faad. Are you sure you have "faad.exe" in the the directory with hymn and the script? It can't be called anything else other than "faad.exe".
If you DO see .wav files in the decoded directory, that means the script is failing trying to encode the wav files into mp3 files. Make sure "lame.exe" is in the directory with convert.vbs, hymn.exe, and faad.exe. Once again, make sure it is called exactly "lame.exe".
If you want the working directory to not be removed after running, simply comment out that line:
removeDirectory(workingDir)
becomes
'removeDirectory(workingDir)
(just a single quote mark in front)
--man on street |
|
| Back to top |
|
 |
legally mine Guest
|
Posted: Wed Aug 18, 2004 2:40 am Post subject: same problem as old guy... |
|
|
man on street... first off thanks for writing the script.
I seem to be having the same problem as old guy. I REM'd out the line to del the working dir The .wav and unprotected files are in there they just don't convert to .mp3's and don't make it into the decoded dir. Any additional insight would be greatly appreciated.
Thanks again
p.s. All the .exe's are in the same dir and named correctly per your above instructions |
|
| Back to top |
|
 |
legally mine Guest
|
Posted: Wed Aug 18, 2004 4:00 am Post subject: add- |
|
|
i ran the script successfully on several folders... however it seems that LAME will occasionally not run... i can't seem to find any rhyme or reason to why this is...
confuselled  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|