Copy custom meta data to meta data

Hi all,

I have a custom meta data field called “date”. It is configured and formatted as “date” via the preferences>data tab.

The field is populated by some other script and I want to use the custom meta data from date to overwrite the “built-in” creation date. I built the following script

on performSmartRule(theRecords)
tell application id “DNtp”
repeat with thisRecord in theRecords
set customMD to custom meta data of thisRecord
set theDate to mddate of customMD
set creation date of meta data of this_record to theDate
end repeat
end tell
end performSmartRule

However the script fails, even if I do not get any error message or the like.

What am I doing wrong?

Thanks very much for your help!

Best
Phil

I only quickly spot this one. U need to put the cmd field with quotation mark, not sure about the other coding.

Edited: This is wrong suggestion, my apology.

set theDate to "mddate" of customMD

There are two issues in the line setting the date, this revision should work:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with thisRecord in theRecords
			set customMD to custom meta data of thisRecord
			set theDate to mddate of customMD
			set creation date of thisRecord to theDate
		end repeat
	end tell
end performSmartRule

Ah, so we can either use mddate directly without quotation mark or "date" if we use the name of cmd at the time of creation?

"key" or |key| is only required if the key is identical to one of the words used by DEVONthink’s script suite or the standard script syntax.

Thank you!

Thank you very much!

  1. Don’t use names for CMD which are close to built-in names. You may get problems afterwards when you will try to use them as columns in view options
  2. Why just not use the “get custom metadata” function?