Quantcast
Channel: Objective Development Forums
Viewing all articles
Browse latest Browse all 4524

Re: Search by tags

$
0
0
For the record:
Save the code below in an applescript file.
Then
1. Bring up the script in launchbar
2. Press space
3. Type the tag name that you want to search for
4. Press return

(Note: You can type "*" i.e. asterisk in search to see all files with tags)

on handle_string(thequery)
   
   try
      tell application "LaunchBar" to hide
      set thecmd to "mdfind  'kMDItemUserTags == " & thequery & "'"
      set theresult to do shell script thecmd
      if theresult is "" then
         tell application "LaunchBar"
            activate
            set selection as text to "No files with this tag found"
         end tell
         return
      end if
      
      set allparas to every paragraph of theresult
      set thelist to {}
      repeat with apara in allparas
         set apara to apara as text
         set end of thelist to apara
      end repeat
      
      
      tell application "LaunchBar"
         activate
         set selection to thelist
      end tell
      
   on error e
      tell me to activate
      display dialog e
   end try
   
end handle_string

Viewing all articles
Browse latest Browse all 4524

Trending Articles