Search by tags

Sharing and discussing custom search templates for LaunchBar
Chandana
Posts: 2
Joined: Thu Jan 09, 2014 1:51 pm

Search by tags

Postby Chandana » Thu Jan 09, 2014 1:52 pm

How do I find an item from Launchbar by using OS X 10.9 tags?

iRounak
Rank 4
Rank 4
Posts: 191
Joined: Fri Oct 23, 2009 7:11 pm
Contact:

Re: Search by tags

Postby iRounak » Sun Mar 16, 2014 11:54 am

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)

Code: Select all

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

Chandana
Posts: 2
Joined: Thu Jan 09, 2014 1:51 pm

Re: Search by tags

Postby Chandana » Sun Mar 16, 2014 12:57 pm

Awesome, thanks!

Kicweed
Rank 1
Rank 1
Posts: 23
Joined: Sun Nov 09, 2008 3:25 am
Contact:

Re: Search by tags

Postby Kicweed » Mon Apr 07, 2014 9:14 am

Just to let you know, the latest LB 6 beta can now play nicely with tags. You can search by tags and also assign tags to items, right inside LB.

Overall it's a great implementation, if you're interested you can request an invite to test LB 6 beta here


Return to “LaunchBar Search Templates”

Who is online

Users browsing this forum: No registered users and 2 guests