Scripting, I guess. Or, depending on the amount of tags, search for those that are not all lower case and change them manually. Although I don’t know how to search for upper-case letters only
in this case, @chrillek may well be your better bet - AppleScript does not contain built in routines for changing the case, and the workarounds are tortuous. JS probably does it in a line or two. And seeing as this would not need to run more than once, it would not need to be embedded into a smart rule.
The following quick & dirty script (run from script editor) will convert the name of marked (selected) records to lowercase. This action CANNOT be reversed. Mind what you select. Test first. Backup your database first. The script will only act on letters A-Z.
Tag groups are not listed in the Tags section of the sidebar and - if required - would need to be dealt with separately. Otherwise you can simply select all your tags by opening the unified tag group and then selecting all tags in the list view.
tell application id "DNtp"
set theRecords to the selection
repeat with theRecord in theRecords
set theName to name of theRecord
set the newName to do shell script "echo " & quoted form of (theName) & " | tr A-Z a-z"
set name of theRecord to newName
end repeat
end tell
Note that converting Newtag to newtag will not automatically merge the latter with an already existing tag called newtag.
(() => {
const app = Application("DEVONthink 3");
const tags = app.search("kind:tag");
tags.forEach(t => {
console.log(t.name().toLowerCase());
/* t.name = t.name().toLowerCase(); REMOVE comments to make it work */
})
})()
Note: This script does NOT yet change the tags, it just prints what it would do to the script editor’s console. In order to actually change the names, one has to remove the comments in the line where it says so. Since
I left the script in a harmless state. Also, toLowerCase() relies on the Unicode definitions of upper and lower case, so there might be border cases (e.g. several asian alphabets have no concept of upper or lower case).
I’m sure that @Blanc’s script works just as well (and I’m always amazed by the detours people are going through to achieve very simple things that AppleScript makes utterly and needlessly complicated Using echo and tr is admittedly one of the simpler solutions to this problem, compared to alternatives in Perl or C or Assembler.).
yours is the better solution, as it does not require selecting tags (but instead searches for them) and uses a more complete definition of upper and lower case.
Do you know of a more beautiful and concise way to say “do what I just told you”?
And btw, tr "[:lower:]" "[:upper:]" is supposed to work for Unicode characters. didn’t test it, though
If, btw., you use the try routine, but don’t add an on error section, then the script will fail silently without any feedback in case of an error. I would recommend either initially leaving out the try routine or adding
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
end try
to your “regular scripting format”. Then you’ll receive feedback of some kind if you have a booboo in your script.
In general is there anything, besides what I would find in the help file, (like forum question, resources, or anything else), that would help getting me up to speed with DT3 automation.
I hope the OP doesn’t mind us hijacking the thread; as far as the forum goes, it will answer a great breadth of questions, but only if you know what you want to ask. So “how do I automate” won’t get you far, “how do I get bills from a utility dated and moved to a group after I have scanned them” will give you answers. I started by using smart rules, which are pretty powerful and relatively self-explanatory. When you hit the limits of what smart rules can do, you need to add in scripting. Again, I learned the little I can do by trial and error and returning to the forum each time I got stuck.