A way to lowercase all tags?

Hi all

I seem over the years to have created many tags which are the same yet some have Capital first letters and some are lowercase.

is there by chance a way to quick change all tags to be lower case to avoid future bloat and less complex text suggestions?



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 :frowning:

thx @chrillek!

haha it seems like every post i posted in the last day resulted in the answer: SCRIPTING! :laughing:

i guess there is no avoiding learning this in more depth…to bad im an idiot when it comes to coding heheh

thx again


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.

1 Like

I suggest

(() => {
const app = Application("DEVONthink 3");
const tags = app.search("kind:tag");
tags.forEach(t => {
  /* 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 :innocent: 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.


1 Like

thx @chrillek and @Blanc !!

as @Blanc suggested i ran @chrillek script and it worked beautifully

thx so much guys


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

1 Like

As a rule, I can do that with my eyes :wink:

1 Like

I guess that you know you could change the tag name in the tag tree and it will propagate the changes to the files.

Hi, could you explain how to do this. I am new to this scripting.

isn’t the regular scripting format

tell application id "DNtp"

	end try
end tell


Nope. It is what one would use to write in AppleScript. Which I didn’t do – my script is in JavaScript. As @Blanc said before:

Which indeed it does.
As to

Of course they could. But depending on the number of tags, it might take a tad longer then simply running a script.

Yes, of course.

Ok, thanks for further explaining that.

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.

1 Like

The upper and lower is what I usually use with tr case changes.

It’s always advisable to leave out try blocks when drafting. As you said, if you use them it will often obscure errors and inhibit learning.

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.

DEVONthink provide a couple of resources for free.


haha i don’t mind at all :slight_smile:

thx again for everyones kind help