Extracting detailed file info (Mac OS X)

Does anyone know how to extract the kind of detailed file info which you can get in the finder using “Get Info”? In particular, I am interested in retrieving info on my .mp3 files like Album, Title, Year recorded, Sample rate, etc.

Please DO NOT point me to any third party plug-ins.


If you don’t like plugins, you can look in MacOSLib …

I do not get these data when I “GetInfo” on a sound file… I have a custom icon, sometimes, but even that, I do not found data to get the image.

On the other hand, with iTunes, we can get these data.

No, I do not have a solution (but I searched).

How about Movie class for audio/video files?

Wasn’t they deprecated in current Xojo ?

No. Movie class is still there for 2013r4.

(Looks like the second part of your question got more attention than the first.)

Step back a second. All data files are filled with… data. Overall, there aren’t too many classes in REAL/Xojo itself that “extract” specific data or metadata out of files and represent them. For example, the Sound object is just to play the sound, it doesn’t show you the samplerate or bitrate or channel characteristics of the sound itself.

Graphic files, sound files, 3D files, all have this type of stuff and generally it’s up to you to find the file format information and parse the file yourself to get this data. MP3 files use what got called the ID3 tag structures and you can google them and find it on the web.

Stepping backwards into your question, OSX and Windows have built-in HANDLERS that parse this information for the purposes of their property sheets (GetInfo). Mostly these aren’t available for others to use. They’ve done the work, but they use it for themselves. You generally have to do the work yourself. Or, if you are looking for someone else to have done the work, you are talking plugins, which you eliminated as a possibility in your second paragraph. This is what plugins or reusable code is primarily for.

Garth, thanks for the helpful reply.

The follow up question would be:

What is the best way to read the raw data from the file so I can parse it?

I think I could extract the info, but I’m not sure exactly how to obtain it. I assume it means grabbing the first few block of data from the file and looking for the ID3 tags.

So, please, what is the best approach to opening a file and reading the required data blocks?

Also, thanks to the other responders.

Binary stream but beware that many file formats are quite complex so parsing them correctly can be a fair amount of work

Thanks Norman.

That sounds like the fun part to me!

My first “computer” was a KIM-1. Hex dumps don’t scare me :slight_smile:

Ed, I agree, the hex sleuthing is fun! But with the specs, which are easy to find, it’s easy to figure it out. Get the ID3 specs and you’ll find it rather easy.

Thanks Garth. I have the file hexed out and have started to look at the spec.

Make sure you look at the latest one.
Older specs didn’t account for tags at the end of the file so if you used that spec then you couldn’t handle all files.
And don’t be too new since that may yet be “draft” and never implemented that way.
Web sockets kind of did this where they published a spec then it changed after a lot had implemented it based on that draft and that draft did not become the final.
And there are certain de facto standard that have no published spec

It’s a joyous thing

[quote=64127:@Ed Stokes]Does anyone know how to extract the kind of detailed file info which you can get in the finder using “Get Info”? In particular, I am interested in retrieving info on my .mp3 files like Album, Title, Year recorded, Sample rate, etc.

Example Read Write id3

Here is another Example - reading mp3 or m4a TAG with an Applescript and a Shell Command.

There are several ways to get this information, NSURL has a whole bunch of functions for getting file information as well as Spotlight APIs.

The MBS will make this relatively easy (especially with documentation and examples), the MacOSLib is FREE, but will take a bit to figure out, where as declares are the hardest.

I know, I made an Audio Player with MacOSLib where I used it.


This is an old post, and all the above links have been corrupted (pointing to Mackeeper, and off the wall media players, and not to anything resembling examples etc).

SO… Does anyone have XOJO code that will read ID3v2.x formats. ID3V1 is super easy.

I need to be able to scan a computer for all MP3 files, and present them in an “iTunes” like manner, to build file packages to transfer directly to a Garmin Zumo GPS unit

Spotlight, you can get the spotlight data for a file. I know the MBS plugin has this functionality. You should look at MDItem.

Check your internet plugins folder and various other places, my brother-in-laws Mac was loaded with some adware on his machine. I think I’ve cleaned it all. There’s some articles on MacWorld for removing this disgusting piece of ■■■■ from your system. Every time he clicked on a link, he got a second window advertising MacKeeper.

Also check in the application support folder (users folder) for a hidden directory called .FUS.