Have you looked at the Automation chapter in the Help?
Understood.
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.
Thanks
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
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 => {
console.log(t.name().toLowerCase());
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)ā¦
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
Look at the targeted group and the Kind criteria in my smart group.
Oh now I see. Iāll just go and stand quietly in the corner for a while
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.
Indeed.