Bulk Editing of Metadata and Custom Metadata

Is it possible to select a group of documents and do a bulk edit to apply a given value to a given metadata or custom metadata field for all items selected?

It seems to me that if I select several documents now, I can in fact edit a custom metadata field and have that change apply to all selected items but only if I start out with the same value for that field for all items.. If I start out with differing values for the field for 1 or more items, then I am unable to edit that metadata field for the whole selected set.

No that is not possible at this time.

Scripting is an option here. It should be easy to script an “Update metadata field [x]” workflow if you’re bulk-editing the same field all the time.

Batch processing might also be an option depending on the desired change.

Agreed - I need to learn a bit more to do that but this is probably just the right level of a project to learn on .

Could you clarify what you are suggesting?

See Tools > Batch Processing… This command supports multiple selections and the actions can change custom metadata.

3 Likes

Happy to help with specific questions about AppleScript. A good start (to get and act on multiple selected records) is:

tell application id "DNtp" -- the following code block operates within DEVONthink and uses the DT AppleScript dictionary
	set theRecords to get the selection -- create a list of records out of the selected records 
	repeat with eachRecord in theRecords -- iterate through the list of records 
		-- do something to eachRecord
	end repeat
end tell

You’ll want to look at the get custom meta data and set custom meta data actions in DT’s AppleScript dictionary, accessible via File → Open Dictionary (I think that’s right) in Script Editor.

2 Likes

Aha! Can’t believe I did not notice that this whole time. Yes that’s perfect - thank you.

I haven’t looked at this before. Neat!

That is simple indeed - thanks. “Batch Process” will work for one-off needs. The script may be helpful for repeated needs and/or in a smart rule. Thanks!

1 Like

After experimenting with this a bit more - it is indeed quite useful -with one tweak. If I want to batch edit a custom metadata field which is a date, I am limited to only a few multiple-choice options. Could this permit entering any arbitrary date?

No such plans right now but noted. Scripting might be an alternative for now.

OK thanks - noted.

“Nice to have” but there are workarounds

@ryanjamurphy

OK I made a good bit of progress using Applescript to edit custom meta data - it is pretty straightforward and very helpful.

I have been able to edit data for both date fields and text fields either by pasting from the keyboard or by hardcoding the value into the Applescript.

What I have not been successful at is editing fields based on the output of a dialog box. Any suggestions on how to tweak this to work with the last two examples?

image

Hm. I’m sure I can help figure this out when I get to my desktop later, but in the meantime—do you get an error? What happens/doesn’t happen?

No error - the earlier parts of the script work and the dialog box appears appropriately - but the final statements to apply the response to the dialog box to two different fields (the date field datecompleted and the text field volume) appear to simply be ignored.

Ah. A good debug trick in AppleScript is display dialog someVariable. After text entry dialog box, put that down with theDateEntered as the variable to get a cancel-able prompt that shows you what the variable actually gets as text.

My guess, though, is that the custom metadata action is having trouble coercing your date text into a date type.

You probably need to write add custom meta data date theDateEntered ..., and you might need to be careful about how you write dates in that text box.

More on dates in AppleScript:
https://macscripter.net/viewtopic.php?id=24737

That is why I was trying this with both a text field (volume) and a date field (datecompleted) - it does not work with either.

When I add “date” as you suggested, the editor rejects the syntax. I can add “text” instead for both fields, but still neither one works.

BTW - Display Dialog does show the expected date

Interestingly, I can enter a date into a date field through the clipboard so there is not a major challenge in terms of string/date format using that method - somehow entering data through a display dialog is harder than entering the data via the clipboard.

You haven’t shown what you’re entering or the value shown in the dialog.