In my previous post, I was a bit off target. DT records have a metadata property that should contain the keywords in your case.
So, in the function addDocument, add this at the end (not tested, since I don’t have appropriate documents), replacing newRecord.name = title;
const keywords = newRecord.metaData().kMDItemKeywords.split('\n');
const kwName = keywords.filter(k => k.includes('Name');
if (kwName && kwName.length) {
const name = kwName[0].split('=')[1];
newRecord.name = name;
}
This snippet assumes that
- the
metaDataproperty contains akMDItemKeywordskey. If that’s not always the case, you must check for its existence before applyingsplitto it. - the
kMDItemKeywordsentry contains keywords separated by newlines. If that’s not the case, changesplit('\n')accordingly - the
Nameentry inkMDItemKeywordscontains the name you’re after - The string
Nameand the name itself are separated by a=sign. If that’s not the case, changesplit('=')accordingly.
The Paperless people must have been a bit weird, storing the dates in US format (the most illogical of all possible formats). But then their AppleScript implementation is borken, and they still sell their software in the App Store although the company has disappeared.