Tag name into custom metadata

hi! question i was hoping someone might be able to help me with. i think its a longshot but i’m regularly surprised on here by how much the system is capable of, so hoping for some help.

i have tons of article in RTF form, all tagged with the date of the article, in the format YYYY-MM-DD. Is there a way to either 1) imprint all the documents with that date near the bottom (assume no because RTF) or 2) somehow copy the tag date to a custom metadata field?

Is this the only tag of these documents?

I suppose that you’d need to script that, but perhaps @cgrunenberg has a better idea.
Something along these lines

(() => {
  const app = Application("DEVONthink 3");
  const selection = app.selectedRecords();
  selection.forEach(rec => {
    const tags = rec.tags();
    tags.forEach(t => {
    if (/\d{4}-\d\d-\d\d/.test(t)) {
       app.addCustomMetadata(t, {for: "yourCustomMedataDataName", to: rec});

Note: This is JavaScript, not AppleScript. So set the language selector in Script Editor to JavaScript before you try to run it. Also, I did not test the script. Run at your own peril, and try it out with copies of your data first.

The script operates on the currently selected records. If more than one tag is of the form YYYY-MM-DD, the last one will prevail.

1 Like