Finder's smart folder

Is there a way to create a smart folder for a Finder search?
For now, I’m creating a savedSearch xml file from scratch but it’s not ideal.
Is there any AppleScriptObjC method or shell script to achieve this?

Alternatively, is it possible to display an array of files in the same Finder window using AppleScriptObjC?

I’ve used that method a number of times over the years, and as far as I know it’s the only one available. Although it’s been quite a while since I seriously researched the topic.

HoudahSpot is AppleScriptable, and in general I like it better than Spotlight in the Finder.

In an actual Finder window? No.

You ought to be able to do something with Shanes Myriad Tables Library though.

I was pretty sure of that.

I’lm using it billions of times each and every day.
And it has a feature to export the search as a smart folder.
But this script is not for me…

This feature is really missing!

Thanks anyway…

You know you can access the search field in a Finder window and emplace a Spotlight search string – yes?

If that level of search is adequate for your needs you could try entering the search specification via UI-Scripting.

This works for me on macOS 10.14.6 Mojave:

# Auth: Christopher Stone <>
# dCre: 2023/01/18 10:53
# dMod: 2023/01/18 10:53 
# Appl: Finder, System Events
# Task: Scripting the Search Field of the Front Finder Window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Finder, @System_Events, @Search, @Field, @Window, @UI-Scripting
# Test: macOS 10.14.6

tell application "System Events"
   tell application process "Finder"
      tell window "Finder"
         tell toolbar 1
            tell group 7
               tell (first text field whose role description is "search text field")
                  set its focused to true
                  set its value to "name:path"
               end tell
            end tell
         end tell
      end tell
   end tell
end tell


Thanks Chris, I’ll give it a try.

1 Like

Its possible to automate savedSearch with GUI scripting. And later you could do backup of your saved files in ~/Library/Saved Searches The goal was if I could make a saved search in few seconds. :wink:

The XML file is very complex and difficult to understand, but its possible to save it.
PyObjC have a demo of NSPredicateEditor but I have never try to do that in AppleScriptObjC.