can you think of a way to list the aliases in any specific group (including subgroups) ? (just list, nothing to do with the search discussed above).
thank you
Iām not sure that I understand the question. But then I never use aliases, and the documentation is (as far as I can see) a bit terse on them.
What are āaliases in a groupā? I see that I can set aliases for records, and presumably for groups. Now, do you want to get the aliases that are defined for this group? Or do you want all alises for all records in this group? Or something else?
A script could perhaps do that, but again: the documentation is not very clear (to me) on that. It says that the aliases property lists the āWiki aliases (separated by commas or semicolons) of a recordā, but is that the same as the āAliasesā I see in the inspector pane (then why is it called simply alias once and āWiki aliasā the other time)? Something else (then how would I go about getting the non-Wiki aliases)?
can I see a dropdown list of all tags so I can scroll down the list if I forget a tag name ?. It must be possible because if I just enter a letter like ācā, a drop down list of all tags starting with C appears
the list of tags is much too long to scroll down even for one letter. I would like to limit the list of tags to only those tags used in the group which the smart group searches.
The following script generates a list of tags, in alphabetical order, that are used by at least one child of the current group. It then creates and opens a plain text document containing the link.
tell application id "DNtp"
set currentWindow to viewer window 1
set theGroup to root of currentWindow
set listTags to {}
if (children of theGroup) is {} then return
repeat with theRecord in (children of theGroup)
set theTags to (tags of theRecord)
repeat with aTag in theTags
if listTags does not contain aTag then set listTags to listTags & aTag
end repeat
end repeat
set listTags to my sortList(listTags)
set textOfList to my convertListToString(listTags, return)
set listRecord to create record with {name:"List of tags", type:txt, content:textOfList} in theGroup
open tab for record listRecord in currentWindow
end tell
on sortList(theList) -- This handler copied from Apple's Mac Automation Scripting Guide
set theIndexList to {}
set theSortedList to {}
repeat (length of theList) times
set theLowItem to ""
repeat with a from 1 to (length of theList)
if a is not in theIndexList then
set theCurrentItem to item a of theList as text
if theLowItem is "" then
set theLowItem to theCurrentItem
set theLowItemIndex to a
else if theCurrentItem comes before theLowItem then
set theLowItem to theCurrentItem
set theLowItemIndex to a
end if
end if
end repeat
set end of theSortedList to theLowItem
set end of theIndexList to theLowItemIndex
end repeat
return theSortedList
end sortList
on convertListToString(theList, theDelimiter)
set AppleScript's text item delimiters to theDelimiter
set theString to theList as string
set AppleScript's text item delimiters to ""
return theString
end convertListToString
Successfully tested in a group containing 10 tagged documents.
Thereās a Set datatype in JavaScript, so we use that instead of checking if an element exists already in the tag list
We can use the union method on the Set object, since Apple has that already implemented in its JavaScript engine. It (the method) takes care of adding every element only once.
From the Set, we can easily build an Array object, which can then be sorted with the aptly named JavaScript method
That is not to say that the AppleScript code is bad ā just a bit chatty
thank you very much. I ran your script via Keyboard Maestro and got the following error message
2024-03-17 15:06:28 Execute a JavaScript For Automation failed with script error: text-script: execution error: Error: TypeError: Object is not a function (near āā¦}ā¦ā) (-2700). Macro āGenerate Dropdown List of Tagsā cancelled (while executing Execute JavaScript For Automation).
I suppose that KM has certain requirements to run JS scripts. This one is meant to be run standalone, you must probably modify it so that it complies with KMās requirements. Notably, (() =>{ at the beginning and })() at the end will probably have to be replaced by a proper function named like KM expects it.
AppleScript apparently can be run in KM without additional restrictions. That can be more friendly for people with no or little prior scripting experience.
It is also stated in the KM documentation that user interaction is disabled when running AS inside KM. Therefore itās not possible to use a dropdown list. My version of the script, which generates a text document without requiring user interaction, might be more suitable in this case.
1- Multiple tags listed with your excellent script are absent from the tags list in the left sidebar. I scrolled down the list 20 times. Would you have an idea of how to troubleshoot this ?
2- I think that I setup DevonThink so that children inherit the parentās tag and that notes automatically inherit the group name as a tag. I may have done this in Evernote many years go before importing in DevonThink. I canāt remember. Would you know if I can configure tags in the DevonThink settings ?
3- I have a zillion tags. I imagine that if I delete many, there is no risk of deleting the notes containing those tags.
2- I think that I setup DevonThink so that children inherit the parentās tag and that notes automatically inherit the group name as a tag. I may have done this in Evernote many years go before importing in DevonThink. I canāt remember. Would you know if I can configure tags in the DevonThink settings ?
Yes, you are using group tags because you have File > Database Properties > Exclude Groups From Tagging disabled and potentially enabled Inherit Tags of Groups.
3- I have a zillion tags. I imagine that if I delete many, there is no risk of deleting the notes containing those tags.
Correct.
This is all discussed in the Getting Started > Tagging section of the built-in Help and manual