I’ve found the way to read/write ID3Tag from MP3 files with VB Script.
Requirement
In order to run the script, you must first download the CDDBControl.dll library file. You can download it here.
Note: it also support WMA format
Click read more to see details.
Installation
After you downloaded it, extract to C:\Windows\System32, and run this command:
C:\Windows\System32\regsvr32 CDDBControl.dll
The Script
Here is an example vb script to read mp3 and wma files in current folder.
'Read ID3Tags
Sub ReadID3Tags(folderPath)
'create FileSystemObject instance
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim folder
Set folder = fso.GetFolder(folderPath)
Dim thefile,ext
Dim id3obj
Set id3obj = CreateObject("CDDBControl.CddbID3Tag")
'enumerate files in the folder
For Each thefile In folder.Files
'select only mp3 And wma files
ext = LCase(Right(thefile.Name, 4))
If ext=".mp3" Or ext=".wma" Then
'load file
id3obj.LoadFromFile thefile.Path, True 'set false if you want to read
WScript.Echo thefile.Name
WScript.Echo "Album : " & id3obj.Album
WScript.Echo "Movie : " & id3obj.Movie
WScript.Echo "Title : " & id3obj.Title
WScript.Echo "CopyrightYear : " & id3obj.CopyrightYear
WScript.Echo "CopyrightHolder : " & id3obj.CopyrightHolder
WScript.Echo "Comments : " & id3obj.Comments
WScript.Echo "Label : " & id3obj.Label
WScript.Echo "BeatsPerMinute : " & id3obj.BeatsPerMinute
WScript.Echo "LeadArtist : " & id3obj.LeadArtist
WScript.Echo "PartOfSet : " & id3obj.PartOfSet
WScript.Echo "TrackPosition : " & id3obj.TrackPosition
WScript.Echo "Year : " & id3obj.Year
WScript.Echo "Genre : " & id3obj.Genre
WScript.Echo "FileId : " & id3obj.FileId
WScript.Echo "ISRC : " & id3obj.ISRC
WScript.Echo
End If
Next
End Sub
'Call the function
ReadID3Tags(".")
Usage
Save the script above, save it to readid3files.vbs, put it on a folder where you keep your mp3 files. Run the command below:
cscript readid3files.vbs
Another Functions
Here is full list functions of the library.
Interfaces:
Interface ICddbID3Tag
GUID: {0306D2A8-B7E2-4EA2-ADC6-78F80D65B1E2}
HelpString: ICddbID3Tag Interface
# Members: Sub QueryInterface(riid as GUID, ppvObj as Void)
# Function AddRef as VT_UI4
# Function Release as VT_UI4
# Sub GetTypeInfoCount(pctinfo as VT_UINT)
# Sub GetTypeInfo(itinfo as VT_UINT, lcid as VT_UI4, pptinfo as Void)
# Sub GetIDsOfNames(riid as GUID, rgszNames as VT_I1, cNames as VT_UINT, lcid as VT_UI4, rgdispid as Long)
# Sub Invoke(dispidMember as Long, riid as GUID, lcid as VT_UI4, wFlags as VT_UI2, pdispparams as DISPPARAMS, pvarResult as Variant, pexcepinfo as EXCEPINFO, puArgErr as VT_UINT)
# Property Get Album as String [property Album]
# Property Put Album as String [property Album]
# Property Get Movie as String [property Movie]
# Property Put Movie as String [property Movie]
# Property Get Title as String [property Title]
# Property Put Title as String [property Title]
# Property Get CopyrightYear as String [property CopyrightYear]
# Property Put CopyrightYear as String [property CopyrightYear]
# Property Get CopyrightHolder as String [property CopyrightHolder]
# Property Put CopyrightHolder as String [property CopyrightHolder]
# Property Get Comments as String [property Comments]
# Property Put Comments as String [property Comments]
# Property Get Label as String [property Label]
# Property Put Label as String [property Label]
# Property Get BeatsPerMinute as String [property BeatsPerMinute]
# Property Put BeatsPerMinute as String [property BeatsPerMinute]
# Property Get LeadArtist as String [property LeadArtist]
# Property Put LeadArtist as String [property LeadArtist]
# Property Get PartOfSet as String [property PartOfSet]
# Property Put PartOfSet as String [property PartOfSet]
# Property Get TrackPosition as String [property TrackPosition]
# Property Put TrackPosition as String [property TrackPosition]
# Property Get Year as String [property Year]
# Property Put Year as String [property Year]
# Property Get Genre as String [property Genre]
# Property Put Genre as String [property Genre]
# Property Get FileId as String [property FileId]
# Property Put FileId as String [property FileId]
# Property Get ISRC as String [property ISRC]
# Property Put ISRC as String [property ISRC]
# Sub LoadFromFile(Filename as String, Readonly as Long) [method LoadFromFile]
# Sub BindToFile(Filename as String, Readonly as Long) [method BindToFile]
# Sub SaveToFile(Filename as String) [method SaveToFile]
# Sub Commit [method Commit]
# Sub Clear [method Clear]
# Sub LoadFromBuffer(Buffer as Variant, BufferSize as Long) [method LoadFromBuffer]
# Function GetBufferSize as Long [method GetBufferSize]
# Sub SaveToBuffer(Buffer as Variant, BufferSize as Long) [method SaveToBuffer]
# Function GetTextFrame(Frame as String) as String [method GetTextFrame]
# Sub SetTextFrame(Frame as String, Text as String) [method SetTextFrame]
Source: Motobit
No related posts.
Tags: cddbcontrol, id3tag, mp3, vbscript, wma
