how to organize loose music files in to folders
Jul 15, 2006 at 3:02 PM Post #16 of 34
If you like to build a new folder structure by the ID3 tags from MP3 and WMA files, then, here is one possible method I wrote just after showing this thread coming back after a while.

This is just a VBScript, which
- uses cddbcontrol.dll (to get wma support, see below) for reading the Artist and Album data from ID3 tags and then
- builds folders using this data --> ..\Artist\Album\ and then
- copies all the file(s) having the same data-'path' into that folder (can be modified to move the file(s) instead of copy, but the copying is just safe)
- processes all files (by the def. of extList) found in the folder the script is executed and in all of it's subfolders (the all.txt lists all found files)

REMEMBER, IF YOU NEED TO RESCAN FILES AGAIN, SCRIPT SCANS THOSE ALREADY MADE FOLDERS TOO IF THEY'RE MADE UNDER THE SAME FOLDER THE SCRIPT IS (this is not what yo want) --> IF YOU DON'T WANT THIS HAPPEN, JUST SET THE FOLDER TO SOMETHING ELSE (EXISTING FOLDER) THAN SUGGESTED (scripts folder is suggested).

The code is not optimized --> not really very fast.

ID3 -part of the script is based on this data and if needed, the CDDBControl.dll (supports MP3 and WMA) can be get least w/ installing the CATraxx trial (NOTE: When you uninstall the CATraxx, uninstaller asks your permission to remove shared components --> select "remove" one by one until you're asked if you want to remove CDDBControl.dll and CDDBUI.dll --> just let those files stay in your system --> otherwise, you may need to backup those 2 files before uninstallation and register DLLs then after uninstallation using the regsrv32).

Here is the code:
(Copy and paste into some ASCII editor (notepad.exe) --> save as, copy-files-2-folders-by-ID3-tags.vbs (or what ever .vbs you like)).


Code:

Code:
[left]Option Explicit Dim objWrite, FSO, objStream Dim filePath, fName, whereTo Dim tFolder, tSubFolder, tFile Dim objFolder Dim lf, extList, strLine Dim id3, wmaID3 Dim fCounting, CopyMove Set id3 = CreateObject("CDDBControl.CddbID3Tag") Set wmaID3 = CreateObject("CDDBControl.CddbWMATag") ' if you have CDDBControlCreative.dll --> just change above DLL parts of names to CDDBControlCreative. Const ForWriting = 2, ForReading = 1 Const TristateFalse = 0 lf = chr(10) fName = "all.txt" fCounting = 0 ' This routine #1 builds a file (All.txt) holding all files having extension defined on extList ' ------------------------------------------------------------------------------------------------ Set FSO = CreateObject("Scripting.FileSystemObject") Set objWrite = FSO.OpenTextFile(fName, ForWriting, True, TristateFalse) ' ' If you add some other extensions and CDDBControl functions don't support those --> files are ' copied/moved into path specified on prompt ' extList = ".mp3 .wma" WriteFileList extList, FSO.GetAbsolutePathName (".") objWrite.close MsgBox "File list created. Press OK to continue ..." & lf & lf & "Next actions : " & lf & "-> Create folders .\Artist\Album\" & lf & "--> Copy or move specified files into new folders." ' Routine #1 Ends ----------------------------------------------------------------------- ' ' Specify the path where the new folders are stored whereTo = Trim(InputBox("Specify the (exsisting) folder you want to store your collection into (like C:\Temp)" & lf & lf & lf & "EXAMPLE:" & lf & "When you enter C:\Temp, your files becomes copied/moved into path C:\Temp\Artist\Album\", "Specify the path for collection.", FSO.GetAbsolutePathName("."))) Select Case whereTo Case "" 'cancel pressed WScript.Quit (0) Case Else 'something inputted ' check if the last char is "\" and remove it if it is If Right(whereTo,1) = "\" Then whereTo = Left(whereTo, Len(whereTo)-1) ' check if the folder exists If Not FSO.FolderExists(whereTo) Then MsgBox "Given folder does not exist!. Script terminated." & lf & lf & "Run script again and specify a folder that exists!" WScript.Quit(0) End If End Select ' Routine #2 Starts --------------------------------------------------------------------- ' Lets open the created all.txt file ' CopyMove = MsgBox("Copying files is defaulted method. Do you want to Move the files instead?" & lf & lf & "NOTE: If file exist already, the MOVE statement gives an error and stops the script from working", 68, "Select method: Copy or Move") Set objStream = FSO.OpenTextFile(fName, ForReading, 1) ' main loop Do While Not objStream.AtEndOfStream ' read one line at a time strLine = LTrim(RTrim(objStream.ReadLine)) ' find the file name from string tFile = Mid(strLine, InStrRev(strLine, "\", -1) + 1) ' Read ID3/WMA Tags and build the paths by the data from files ' (This routine needs the CDDBControl.dll being registered into your system. ' See instructions : http://www.motobit.com/tips/detpg_change-id3-tags-script/) ' if you dl the dll needed, be sure you get one w/ both mp3 and wma tagging is supported Select Case LCase(Right(strLine, 3)) Case "mp3" id3.LoadFromFile strLine, False tFolder = whereTo & "\" & id3.LeadArtist tSubFolder = tFolder & "\" & id3.Album Case "wma" wmaID3.LoadFromFile strLine, False tFolder = whereTo & "\" & wmaID3.LeadArtist tSubFolder = tFolder & "\" & wmaID3.Album Case Else End Select ' Now, lets create folder by the Artist and Album --> ..\Artist\Album\ ' Artist If Not FSO.FolderExists(tFolder) Then FSO.CreateFolder(tFolder) ' Album If Not FSO.FolderExists(tSubFolder) Then FSO.CreateFolder(tSubFolder) ' Now lets copy/move the file to it's new path (rem the unused statement) Select Case CopyMove Case 6 ' move the file to the new path FSO.MoveFile strLine, tSubFolder & "\" & tFile Case 7 ' (safely) copy the file to the new path FSO.CopyFile strLine, tSubFolder & "\" & tFile, True End Select ' Count the files processed fCounting = fCounting + 1 Loop ' DONE, lets Quit the script MsgBox "All matching " & fCounting & " files copied or moved to new locations." & lf & lf & "Press OK to end the script." WScript.Quit(0) ' ----------------------------------------------------------------------------- ' This function scans directories for files defined w/ extList ' ----------------------------------------------------------------------------- Public Function WriteFileList (fExtToFind, sPath) Dim curFName, extForCurFile Set tFolder = FSO.GetFolder(sPath) For Each tFile In tFolder.Files curFName = tFile.Name extForCurFile = Right(curFName, len(curFName) - (InStrRev(curFName,".", len(curFName))-1)) if InStr(1, Ucase(fExtToFind), Ucase(extForCurFile), 1) Then if filePath = "" Then filePath = sPath & "\" & tFile.Name Else filePath = filePath & "," & sPath & "\" & tFile.Name End if objWrite.WriteLine filePath filePath = "" End if Next For Each tSubFolder In tFolder.SubFolders Call WriteFileList(fExtToFind, sPath & "\" & tSubFolder.Name) Next End Function[/left]


I have tested the script w/ MP3, WMA, APE and OGG files --> only MP3 and WMA worked as expected --> removed other extensions from the extList.

If you're unsure to use this method, you can copy some tens of your files into some safe location and try w/ those. Script builds the new folders under that folder it's excecuted (if you don't specify another), and it also builds the all.txt (database) under same folder.

Here are some more VBScripts I have published on this forum (for quick ASX, M3U, PLS and WPL playlist generation).

jiitee
 
Jul 15, 2006 at 4:04 PM Post #18 of 34
Quote:

Originally Posted by Sparky191
I assume that will only work if your tags are tagged consistently. If their not you'll have a mess.


Yes, artist name on artist name tag field and album name on album name tag field --> isn't this the std way to put ID3 data ?

Everything tag related are specified on that dll this script uses (it's made by Creative, least in my case).

There are some possibilities to get strange folder naming but the script running in most cases just stops, and shows an error message --> and when you actually don't change anything original, does it matter?


jiitee
 
Jul 15, 2006 at 4:22 PM Post #19 of 34
I find tags very inconsistent. Especially for Compilations and mixed artist, classic and soundtrac stuff. Thats why I use MediaMonkey it lets you preview the results of a organising files and folders by tags, correct them etc. It also allows you to see the tag and the filepath at the same time. I don't know any other app that does that.
 
Jul 15, 2006 at 8:14 PM Post #20 of 34
There were a 'BUG' --> somehow I lost the " mark from the extList definition, so it gave an error --> Now it's Fixed.

I propably add some functionality later (like renaming capability (i.e. user can accept/rename the path name(s) before making them), naming checking, etc.). Maybe someone can suggest some neat features (w/ remembering the limitations in VBS though).


Quote:

Originally Posted by Sparky191
I find tags very inconsistent. Especially for Compilations and mixed artist, classic and soundtrac stuff. Thats why I use MediaMonkey it lets you preview the results of a organising files and folders by tags, correct them etc. It also allows you to see the tag and the filepath at the same time. I don't know any other app that does that.


Hmm... IMO, everybody can make as complicated naming systems as they like --> this we're dealing here with, is just question of to put mass of files into order by some given data. If you have not prepared the tag data the way, every piece (track) on the album have equal artist/album names, it's your desicion. If you have made everything correctly, you don't need to edit anything. Also, it's not very difficult to prepare those features you're listing for Monkey (I could make them to this script if I just want to). Also, it's not very hard to rename some folders using windows explorer either.

jiitee

EDIT: Added some features like
- save path can be set (i.e. where those folders artist and album are created)
- selection b/w copy and move source files to created new paths
- some general checkings

jiitee
 
Jul 15, 2006 at 8:31 PM Post #21 of 34
This should have been a function of XP. You can make certain folders 'Music' specific.
It should have been an option to arrange files in these folders using their tags or leaving them as you place them in sub-folders manually.
 
Jul 17, 2006 at 1:39 PM Post #22 of 34
Updated the script. It reads needed (Artist, Album) tags now (least) from MP3 and WMA files.

If not SB user (you should have CDDBControlCreative.DLL instaled w/ CT software --> see changes needed on remarks in code),
- you need to find and register the CDDBControlCreative.DLL or CDDBControl.DLL w/ WMATag support to get the WMA tags read from files.

As suggested, CATraxx demo installs required DLL int system32 -folder.

jiitee
 
Jul 17, 2006 at 1:50 PM Post #23 of 34
Quote:

Originally Posted by Chri5peed
This should have been a function of XP. You can make certain folders 'Music' specific.
It should have been an option to arrange files in these folders using their tags or leaving them as you place them in sub-folders manually.



Whats it got to do with the OS? Your music manager can do all of this. Which is the right place for this functionality.

jiiteepee - Why the script? AFAIK MediaMonkey already does all of this.
 
Jul 17, 2006 at 2:11 PM Post #24 of 34
Quote:

Originally Posted by Sparky191
Whats it got to do with the OS? Your music manager can do all of this. Which is the right place for this functionality.


It'd hardly be a hard thing to implement. Both of my DAPs can do it for gods sake!
 
Jul 17, 2006 at 2:35 PM Post #25 of 34
Quote:

Originally Posted by Chri5peed
It'd hardly be a hard thing to implement. Both of my DAPs can do it for gods sake!


Its not about difficulty, The thing is, the OS shouldn't do it.

You'll find every different brand DAP, Apple, Creative etc does it differently.

Why should music files be organised (by the OS) differently than any other type of data. The answer is they shouldn't. Its just data.
 
Jul 17, 2006 at 4:12 PM Post #26 of 34
Quote:

Originally Posted by Sparky191
Its not about difficulty, The thing is, the OS shouldn't do it.

You'll find every different brand DAP, Apple, Creative etc does it differently.

Why should music files be organised (by the OS) differently than any other type of data. The answer is they shouldn't. Its just data.



This is something small that should have been incorporated. Whether an OS should do something or not is of no concern, an OS, especially Windows is supposed to be extremely user-friendly.
Its like the MacOS, it just does stuff you'd not expect it to do, but you find invaluable.

If WinME had done it, it would not be of any concern now.
 
Jul 17, 2006 at 7:24 PM Post #28 of 34
sparky, I see that there's the my computer thing, but to actually do physically put them in folders using mediamonkey, what do I do?

I can't see the files, because they're loose in my documents, but I do have some folders there which I can see. I think I'll use the script if I don't get any other suggestions.
 
Jul 17, 2006 at 7:53 PM Post #29 of 34
Quote:

Originally Posted by litlharsh
sparky, I see that there's the my computer thing, but to actually do physically put them in folders using mediamonkey, what do I do?

I can't see the files, because they're loose in my documents, but I do have some folders there which I can see. I think I'll use the script if I don't get any other suggestions.




On MediaMonkey:
- go to the folder the fileas are (or just select all from list).
- Tools --> Auto Organize Files ...
- select the 'tags' to destination field (just klicking <xxxxx> fields (remember add spaces and separators (\ for folder, etc.)


monkeybusinessdb8.jpg


Remember, if you use the script, it supports mp3 and wma files only. Good thing is if you execute the script from say c:\ it lists and processes all mp3 and wma files from that disk.

jiitee
 
Jul 17, 2006 at 8:08 PM Post #30 of 34
Quote:

Originally Posted by Sparky191
Your missing the point.

Metadata has nothing to do with the file system, or the OS.



You're unable to type in English properly.

It doesn't matter if the Metadata has nothing to do with the file system or OS, although thats your opinion. Theres a name for people who only follow the precise letter of their job contract and never do anything outside this to maybe help someone; Jobsworth's.
So you think the OS shouldn't be doing this sort of thing? Even though its hardly a completely alien task.
 

Users who are viewing this thread

Back
Top