A bit of background: I’m not a novice at automating DEVONthink, but I’m a bit stumped for one step.
I scan in receipts, bills, etc. directly to DT3, and once scanned, the document name in the Inbox has the format 2021-03-14-14-51-59.pdf . I like to have similar receipts and bills named the same other than the date on the receipt or bill, so I use “See Also and Classify” to see how I’ve previously named similar receipts or bills, right click on one of the discovered documents, choose “Get Info”, and copy the filename I previously used, such as 2021-01-26 Anton’s Cleaners.pdf, paste it onto the scanned document’s name, and use a script to update the date to the Document Date. I would love to be to able to choose a document in “See Also and Classify”, and use a script to copy that document name to the clipboard or otherwise extract the document name, so I can then use it for the newly scanned document. That’s where I’m stuck - how to obtain the name of the highlighted file in “See Also and Classify”. Any hints? Thanks!
There’s no direct way to act on a selected “See Also” record but it’s possible to do the
See Also comparison in AppleScript by using the
compare command. You could then use the results to directly copy the name of e.g. the first result or show a list of all results.
This script shows a list and moves the selected record to the chosen “See Also” record’s parent group. You could use parts of it to do what you want. If you need help let me know.
@pete31 Thanks for the quick reply! I’ll give it a shot and let you know if I need any help.
@pete31 Thanks again for your help. As a follow-up, I now have a script that does exactly what I want. Here are the diffs from the script you recommended:
< -- Move record to See Also suggestion's parent group
> -- Rename record from See Also suggestion's name
< property deduplicate : true -- deduplicate group names
> property deduplicate : false -- deduplicate group names
< set thisName_truncated to my truncateText(name of thisParent)
> set thisName_truncated to my truncateText(name without extension of thisResult)
< set theUUID to item 2 of paragraphs of (item 1 of theChoice)
< set theGroup to get record with uuid theUUID
< move record theRecord to theGroup
> set theChoiceName to item 1 of paragraphs of (item 1 of theChoice)
> set nondatedChoiceName to do shell script "echo " & quoted form of theChoiceName & " | sed 's/^....-..-.. //'"
> set name of theRecord to nondatedChoiceName
Starting at the top, I want more than one result in each group, so I set deduplicate to false.
I wanted to list the “See Also” document names rather than their groups, so rather than display “name of thisParent” in the list, I display “name without extension of thisResult”.
Rather than moving the original record, I rename the record using the chosen document name. Many of my documents have a leading document date that will just be replaced anyway, so I use sed to remove the leading date if there is one.
And that’s it! Thanks again.