How do I alter kMDItem meta data

I would like to be able to store some information along with the file rather than in a seperate database. There seem to be kMDItem keys that I could use, I can retrieve the current list for kMDItem with “mdls”. But how do I add/alter the kMDItem header information?

Hi,

You can edit kMDItemFinderComment pretty easily from Applescript. You can also retreve it from Applescript.

tell application "Finder"
	set myFile to (choose file)
	set (comment of myFile) to (comment of myFile) & "  Hey, hi, look at me... over here!!!"
	set myComment to (comment of myFile) as Unicode text
end tell

set mdlsResponse to (do shell script "mdls " & quoted form of POSIX path of myFile) as Unicode text

Best wishes

John M

Great. I had no idea it would be so easy.:slight_smile:

What about other common attributes like?
http://developer.apple.com/documentation/Carbon/Reference/MetadataAttributesRef/Reference/CommonAttrs.html

I’ve been trying to find an easier way to alter some kMDItems, than to write my own Spotlight Importer in Objective-C !!

Can you help me to set kMDItemRecordingYear or kMDItemRecordingDate with an Applescript or any program you know?
This is for .eyetv video files of old video I’m importing and cataloging.

Thanks for any help,
HalliEym

Hi HalliEym,

I don’t think you can set other meta data values without at least creating a Foundation Tool (although I’d be delighted to be wrong). See http://developer.apple.com/documentation/Carbon/Conceptual/MDImporters/Concepts/WritingAnImp.html#//apple_ref/doc/uid/TP40001275-208147 for the basic code to do this.

Best wishes

John M