Smart Group, update "Search in:" to match folder name when duplicating smartgroup

I use Smart Groups to find and highlight keywords in documents for specific projects. When I create a new project, I duplicate the Smart Groups I have created, and manually update the “Search in:” field.

Is anyone aware of a way to make the “Search in:” field update dynamically. My preference would be to have a template group with the smart groups enclosed. I would duplicate and rename the template group, and the enclosed Smart Groups “Search in:” reference would update automatically to the the newly duplicated group name

E.g.:

If the template were:
“Template group” > Smart Group [Search in: “Template Group”]

Then, when I duplicate and rename the template, the search in would update automatically to match the group name:
“New name” > Smart Group [Search in: “New name”]

Is this possible?

A script could handle this, here’s a basic example to create a new project:

tell application id "DNtp"
	set theName to display name editor info "New Project:"
	if theName is not "" then
		set theGroup to create record with {name:theName, type:group} in current group
		set theSmartGroup to create record with {name:theName, type:smart group} in theGroup
		set search predicates of theSmartGroup to "text:" & theName
		set highlight occurrences of theSmartGroup to true
	end if
end tell

Good morning, thanks for the reply :slight_smile:

I’m not familiar with code, but I will look into it and then see if this works.

Thanks again!

Welcome @0coade

To use and save the script for future use…

  1. Open /Applications/Utilities/Script Editor.app.
  2. Paste the desired code.
  3. Select Script > Compile to ensure it’s compiling properly.
  4. Select File > Save.
  5. In the Save dialog, press Command-Shift-G and paste ~/Library/Application Scripts/com.devon-technologies.think3/Menu. You can save into that directory or a subfolder of your choice.
  6. Give the script your desired name and save it. The script should now be available in the Scripts menu in DEVONthink.

Thank you very much, I was able to execute the script, and was wondering how to get it into the scripts menu.

You’re welcome :slight_smile: