Can I change meta data of RTF file with a script?

I made a script to change meta data, and it changes them without mistakes, but… after reloading DT all changes are gone. What’s going on? Am I doing something wrong?

Here is a handler to do it (which works also fine with custom meta data):

on SetMD(theLabel, theValue, theDoc)
	tell application id "DNtp" to set theFields to meta data of theDoc
	try
		theFields
	on error number -2753
		set theFields to {}
	end try
	set theField to {}
	set theField to set user property theLabel in theField to theValue
	set theFields to theField & theFields
	tell application id "DNtp" to set meta data of theDoc to theFields
end SetMD

PS
You will need Latenight’s List and Records scripting addition for this handler to work

The meta data AppleScript property is read-only.

1 Like

Ooh can this be changed in a future release? I have been mentally planning out a system to track precedents and cross-references in court judgments but it would rely on writable metadata. I suppose I could dump info into separate text files…

You know what would be great is a parser for yaml or json to allow metadata storage in sidecar files in an open standard format…

This is planned for future releases. In the meantime you could use custom metadata instead, this does not depend on the file format and its supported document properties.

Yes, I use Custom MD for many reasons, but my side inspector becoming very “long” and hard readable… We need a way to order MD fields there, like labelled collapsible dividers or so