Sonoma Breaks AppleScript for Finder Search/Find
macOS Sonoma broke my AppleScript that sets the criteria for Finder search.
BACKGROUND
Finder defaults to search "by Kind". I don’t want that. I want it to default to "Name begins with".
Finder’s SearchCriteria dictionary is this file:
/System/Library/CoreServices/Finder.app/Contents/Resources/default_smart.plist
You could modify the key in this file. However, no matter what you do — quit Finder, use sudo in Terminal, etc. — macOS tells you that you do not have permission to mess with that file. You can’t even replace this default_smart.plist with your saved version.
The alternative is an AppleScript. Until Sonoma, this worked:
tell application "System Events"
tell process "Finder"
click menu item "Find" of menu "File" of menu bar 1
tell pop up button 1 of group 2 of splitter group 1 of window 1
click
delay 0.05
click menu item "Name" of menu 1
end tell
tell pop up button 2 of group 2 of splitter group 1 of window 1
click
delay 0.5
click menu item "begins with" of menu 4
end tell
end tell
end tell
But Sonoma broke the last line, returning this error message:
System Events got an error:
Can’t get menu 1 of pop up button 2 of group 2 of splitter group 1 of window 1 of process "Finder". Invalid index.
Changing the index number has no effect. Does anyone have a solution to this problem?
Thanks.
Mac Studio (2022)