A way to lowercase all tags?

Have you looked at the Automation chapter in the Help?


Thanks for sharing your experiences in how you did it.

Yes, as I mentioned in my post I looked at the help file. I was hoping for a more of something that guides the learning experience.

I think I have enough now to go on to get me started.


It is worth noting that actions undertaken by smart rules and scripts cannot be undone. A smart rule like this could pretty much ruin the best of days:

I have set up a test database for trying things out. I also make regular backups of my databases.

Play with automation in a safe environment; if in doubt close any databases which are important. And when you get stuck, come back to the forum, ideally post screenshots of what you have set up and explain what you are trying to achieve. And ppl will help :slight_smile:

I’ve been trying to use this as part of a smart rule. It appears to work initially but on subsequent tries it fails until I quit and restart DEVONthink.

function performsmartrule(records) {
	var app = Application("DEVONthink 3");
	app.includeStandardAdditions = true;
	records.forEach (r => {
(() => {
const app = Application("DEVONthink 3");
const tags = app.search("kind:tag");
tags.forEach(t => {
  t.name = t.name().toLowerCase();

I don’t have any knowledge of JavaScript but does this looks right @chrillek? I just tested it and and it seems to be working as expected now.

No, it does not. You included the complete self-executing anonymous function in the performsmartrule function. Which is pointless. As is defining app twice and writing the output to console – you can’t ever see that in a smart rule script.
Change the inner part of the code to

records.forEach (r => {
const tags = app.search("kind:tag");
tags.forEach(t => {
  t.name = t.name().toLowerCase();

This is without warranty, I didn’t test the code at all.

I understand that you do not know JavaScript. But if you want to use it, you should learn at least the basics.

I’m curious… are you using this as a smart rule to keep lowercasing any future tags as well?

Yes that’s the idea… unless there’s a better way to force tags to lowercase? I know the Discourse forum software has such an option but I couldn’t find anything like that in DEVONthink’s preferences.

If @chrillek’s idea works, use it.
Here’s an AppleScript alternative with a simple shell call…

And another alternative using AppleScript Objective-C (ASOC)

1 Like

I do prefer AppleScript where possible so thank you for giving me an alternative. However on testing it appears to change the name of the record to lowercase, not the tags?

Post a screencap of your smart rule.

Um, Jim, seeing as both scripts you posted basically end with set name of theRecord I don’t see how they could fail to change the name of the record rather than change the tags :see_no_evil:

Look at the targeted group and the Kind criteria in my smart group.

1 Like

Oh :hugs: now I see. I’ll just go and stand quietly in the corner for a while :see_no_evil:

1 Like

At least we all learned something cool (and I don’t mean using tr to convert strings to lowercase which is necessary because AS has no built-in function for that).

As an aside @BLUEFROG: this tr command only works for ASCII letters. A more robust approach would be
tr "[:upper:]" "[:lower:]"
Or, of course, the ObjC method or, even more of course, Javascript’s tolower method.

1 Like


1 Like

Indeed. :slight_smile: