jiiteepee
Headphoneus Supremus
- Joined
- Apr 5, 2005
- Posts
- 1,606
- Likes
- 62
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:
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
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