Sunday, February 23, 2020
  • Index
  •  » Code Exchange
  •  » AppleScript that use Smart Folder to Search specific string.

#1 2020-02-11 07:56:22 pm

Fredrik71
Member
Registered: 2019-10-23
Posts: 84

AppleScript that use Smart Folder to Search specific string.

AppleScript that use Smart Folder that you have saved, search with a string.

Lets say you have a handler that use 'NSRegularExpression' but do not remember the name or library.

If you create 'smart folder' in finder that only look for scpt, scptd kind..

In the display dialog we could then type: content:NSRegularExpression

Or why not have a list of Saved Searches to pick the one that suite the best.

Applescript:

(*
   AppleScript that use saved SmartFolder to look for search string.
*)


property SavedSmartFolder : "YOUR SAVED SMART FOLDER NAME"

set searchString to (display dialog "Type the search you want:" default answer "Cooking")'s text returned

-- Set saved smart folder name
set smartFolderName to SavedSmartFolder

-- Saved Searches Directory
set smartFolderDir to ((path to library folder from user domain as text) & "Saved Searches:")
set smartFolderPathHFS to smartFolderDir & smartFolderName

log smartFolderPathHFS

tell application "Finder"
   try
       if searchString = "" then
           error number -128
       else
           activate
           open alias smartFolderPathHFS
           set bounds of front window to {50, 45, 1240, 800}
       end if
   end try
end tell

tell application "System Events"
   try
       if searchString = "" then
           error number -128
       else
           keystroke "f" using {command down}
           keystroke searchString
           keystroke return
       end if
   end try
end tell

/Fredrik

Last edited by Fredrik71 (2020-02-12 04:18:28 am)

Offline

 
  • Index
  •  » Code Exchange
  •  » AppleScript that use Smart Folder to Search specific string.

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)