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.
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.
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.
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!
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?
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?
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.
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.