Script help to copy metadata from field into another

I very much appreciate any help or guidance on this.

My goal is to simply run a little script on selected items that batch-copies the NAME field into a newly-created metadata field called “Original Name” or something like that. Thanks in advance!

This is not tested

-- Copy name without extension into custom meta data "Original Name"

tell application id "DNtp"
	try
		set theRecords to selected records
		if theRecords = {} then error "Please select some records"
		
		repeat with thisRecord in theRecords
			set thisName to name without extension of thisRecord
			add custom meta data thisName for "Original Name" to thisRecord
		end repeat
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell


@pete31 you are amazing!

Stuck that bugger in a new folder called “metadata” on my scripts menu, within DT. It worked like a charm. Thanks a ton! …I can copy this script and repurpose it for similar uses.

Cheers!
Ryan

2 Likes