Page 1 of 1 1
Topic Options
#162940 - 2006-06-06 12:42 PM Read ID3 tag information
Leon Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 5
Right I'm trying to knock up a script that can read the information held within the ID3 tags on an mp3 file using KIX.

I'm primarily concerned with reading the information but long term the ability to change the tag would be useful.

I've not been able to find any useful information on this so far so any help will be much appreciated.

Top
#162941 - 2006-06-06 12:52 PM Re: Read ID3 tag information
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, you need to open the file for reading.
if you do normal readline stuff, it is rather cryptic.
other option is to use kixforms .net's binary file reading capabilities.

but anyways, it can be rather not that simple.
_________________________
!

download KiXnet

Top
#162942 - 2006-06-06 12:55 PM Re: Read ID3 tag information
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Found a VBScript that does this (so they say). I’m almost blind in the VBS world so maybe someone else can try to convert it to kix?

http://www.motobit.com/tips/detpg_list-id3-tags-script/

Code:

'List of all mp3 files In one folder
'Read it's id3 tags
'2005 Antonin Foller, Motobit Software
Sub ListID3Tags(sFolder)
'get FileSystemObject To enumerate files
Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")

'call ListID3TagsFS Function with a folder object
ListID3TagsFS FS.GetFolder(sFolder)
End Sub

Sub ListID3TagsFS(Root)
Dim SubFolder, File

'enumerate all files In the folder
For Each File In Root.Files
'select only mp3 And wma files
Select Case LCase(Right(File.Name, 4))
Case ".mp3", ".wma": ListID3TagsFile File
End Select
Next

'process all subfolders
For Each SubFolder In Root.SubFolders
ListID3TagsFS SubFolder
Next
End Sub

Sub ListID3TagsFile(File)
'Get id3 object To change data
Dim id3: Set id3 = CreateObject("CDDBControl.CddbID3Tag")

'load id3 data from a file, read only
id3.LoadFromFile File.Path, True

'print some of id3 tags
WScript.Echo File.Name, id3.Album, id3.Title, id3.LeadArtist
End Sub

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#162943 - 2006-06-06 02:03 PM Re: Read ID3 tag information
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
While not a solution to make changes to those settings, GetExtFileProperties() - Get Extended File Properties / Attributes of Files , will get many of the tags of a MP3.
Top
#162944 - 2006-06-07 11:46 AM Re: Read ID3 tag information
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Here's a script I've been toying around with, haven't gotten all the properties yet and basically abandoned the project since it's dependable on cbbdcontrol.dll which gets installed with all soundblaster enabled audio cards. I'll post my Windows version later if I find it.
It's based upon the same VBS script as Mart displayed.

just use ListID3Tags("C:\Folderhere")
Code:

Function ListID3Tags($sFolder)
Dim $FSO
$FSO = CreateObject("Scripting.FileSystemObject")
ListID3TagsFS($FSO.GetFolder($sFolder))
EndFunction

Function ListID3TagsFS($Root)
Dim $SubFolder, $mp3
For Each $mp3 In $Root.Files
If LCase(Right($mp3.Name, 3)) == "mp3"
ListID3TagsFile($mp3)
EndIf
Next
For Each $SubFolder In $Root.SubFolders
ListID3TagsFS($SubFolder)
Next
EndFunction

Function ListID3TagsFile($mp3)
Dim $id3
$id3 = CreateObject("CDDBControl.CddbID3Tag")
$id3.LoadFromFile($mp3.Path,1)
? "File Name: " $mp3.Path
? "Artist: "$id3.LeadArtist
? "Title: " $id3.Title
? "Album: " $id3.Album
? "Comment: " $id3.Comments + @CRLF
EndFunction



Side Note: The cddbcontrol will enable you to change the file tag information as well, the windows version will not.


Edited by apronk (2006-06-07 11:50 AM)

Top
#162945 - 2006-06-07 08:50 PM Re: Read ID3 tag information
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
And here the windows version as promised, basically using the 'GetDetailsOf' property. Unfortunately as far as I know windows won't let you change any info.

Code:

Function fnGetDetailsOf()
dim $objShell
dim $objFolder
$objShell = CreateObject("Shell.Application")
$objFolder = $objShell.NameSpace("D:\MP3")
If $objFolder <> ""
dim $objFolderItem
$objFolderItem = $objFolder.ParseName("Guns N' Roses - Madagascar.mp3")
If $objFolderItem <> ""
dim $objInfo
? "File Name: " $objFolder.GetDetailsOf($objFolderItem, 0)
? "File Size: " $objFolder.GetDetailsOf($objFolderItem, 1)
? "File Type: " $objFolder.GetDetailsOf($objFolderItem, 2)
? "File Date Modified: " $objFolder.GetDetailsOf($objFolderItem, 3)
? "File Date Created: " $objFolder.GetDetailsOf($objFolderItem, 4)
? "File Date Accessed: " $objFolder.GetDetailsOf($objFolderItem, 5)
? "File Attributes: " $objFolder.GetDetailsOf($objFolderItem, 6)
? "File Status: " $objFolder.GetDetailsOf($objFolderItem, 7)
? "File Owner: " $objFolder.GetDetailsOf($objFolderItem, 8)
? "File Author: "$objFolder.GetDetailsOf($objFolderItem, 9)
? "File Title: " $objFolder.GetDetailsOf($objFolderItem, 10)
? "File Subject: " $objFolder.GetDetailsOf($objFolderItem, 11)
? "File Category: " $objFolder.GetDetailsOf($objFolderItem, 12)
? "File Pages: " $objFolder.GetDetailsOf($objFolderItem, 13)
? "File Comments: " $objFolder.GetDetailsOf($objFolderItem, 14)
? "File Copyright: " $objFolder.GetDetailsOf($objFolderItem, 15)
? "File Artist: " $objFolder.GetDetailsOf($objFolderItem, 16)
? "File Album Title: " $objFolder.GetDetailsOf($objFolderItem, 17)
? "File Year: " $objFolder.GetDetailsOf($objFolderItem, 18)
? "File Track Number: " $objFolder.GetDetailsOf($objFolderItem, 19)
? "File Genre: " $objFolder.GetDetailsOf($objFolderItem, 20)
? "File Duration: " $objFolder.GetDetailsOf($objFolderItem, 21)
? "File Bit Rate: " $objFolder.GetDetailsOf($objFolderItem, 22)
? "File Protected: " $objFolder.GetDetailsOf($objFolderItem, 23)
? "File Camera Model: " $objFolder.GetDetailsOf($objFolderItem, 24)
? "File Date Picture Taken: " $objFolder.GetDetailsOf($objFolderItem, 25)
? "File Dimensions: " $objFolder.GetDetailsOf($objFolderItem, 26)
? "File Not Used: " $objFolder.GetDetailsOf($objFolderItem, 27)
? "File Not Used: " $objFolder.GetDetailsOf($objFolderItem, 28)
? "File Not Used: " $objFolder.GetDetailsOf($objFolderItem, 29)
? "File Company: " $objFolder.GetDetailsOf($objFolderItem, 30)
? "File Description: " $objFolder.GetDetailsOf($objFolderItem, 31)
? "File File Version: " $objFolder.GetDetailsOf($objFolderItem, 32)
? "File Product Name: " $objFolder.GetDetailsOf($objFolderItem, 33)
? "File Product Version: " $objFolder.GetDetailsOf($objFolderItem, 34)
EndIf
$objFolderItem = ""
EndIf
$objFolder = ""
$objShell = ""
EndFunction



Just call for: fnGetDetailsOf()
You'd have to edit the path and mp3 in the function for now, like I said it's WIP so I haven't optimised it yet, was just testing the GetDetailsOf stuff, haven't bothered to really continue it yet.

Top
#162946 - 2006-06-17 10:18 AM Re: Read ID3 tag information
Leon Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 5
Thats spot on dude! Excellent... Cheers for the input everyone. I've managed to do pretty much what I need to for the moment. I'm gonna stick to just reading the info for now.

Thanks

Top
#186762 - 2008-04-06 11:18 PM Re: Read ID3 tag information [Re: Leon]
dennywong Offline
Just in Town

Registered: 2008-04-06
Posts: 3
I'd like to know then, is there a way for me to attach a jpg to the mp3? So say I got this "BryanAdam.mp3" and I have bryanadam.jpg on my C:\ drive, what CDDBControl.DLL method do I use to link (or embed) the image to the mp3 file?
Thanks
Denny

Top
#186769 - 2008-04-07 05:40 AM Re: Read ID3 tag information [Re: dennywong]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
On an NTFS volume you could use ADS
How To Use NTFS Alternate Data Streams

Top
#186777 - 2008-04-07 06:16 PM Re: Read ID3 tag information [Re: NTDOC]
dennywong Offline
Just in Town

Registered: 2008-04-06
Posts: 3
Hi NTDOC, thanks for your reply... I'm not sure if I understand your message at all, is it a reply to my question? I want to know how to embed a jpg into mp3 with the CDDBControl.dll, and I was hoping there would be a function or method to do that, even though I couldn't find any.....

Thanks again

Top
#186783 - 2008-04-07 11:14 PM Re: Read ID3 tag information [Re: dennywong]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Yes it was in reply but I suppose my fault for taking the word EMBED out of context.

I think what you're wanting to do is update the ID record tags - which so far no one has shown that it can be done with that object.

Sorry for the confusion.

Top
#186789 - 2008-04-08 10:37 AM Re: Read ID3 tag information [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
I could be wrong off course but as far as I know there is no way to include an jpg in the ID3 tag.
Top
#186977 - 2008-04-16 07:53 PM Re: Read ID3 tag information [Re: Arend_]
dennywong Offline
Just in Town

Registered: 2008-04-06
Posts: 3
Thanks guy... But I just want to make sure I'm not crazy: there are in fact ways that you can attach and embed an jpg into an mp3 file, maybe just not with DLL, right? (That's why the image will show up in the Media Player when I play that mp3 file)
Top
#186979 - 2008-04-16 08:20 PM Re: Read ID3 tag information [Re: dennywong]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
I'm not speaking on any kind of programming experience, but from cleaning up files and having my hidden files shown. WMP downloads all sorts of hidden files (if enabled), and if memory serves me, the names are like AlbumArt______.jpg. I thought if you deleted these files, the album covers did not show up, but just looking at some of my recent downloads from Amazon, all seem to have a pic and there is no noticable jpgs.

Now you got me wondering....

Top
#186999 - 2008-04-17 03:36 AM Re: Read ID3 tag information [Re: Allen]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Actually, ID3v2.3+ supports the APIC tag, see http://www.id3.org/id3v2.4.0-frames in section 4.14.
_________________________
There are two types of vessels, submarines and targets.

Top
#187091 - 2008-04-18 07:14 PM Re: Read ID3 tag information [Re: Sealeopard]
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
You can put pictures in mp3's, just don't know how to via COM...
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.069 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org