Full name search action?

General discussions about LaunchBar
luckylindy
Posts: 5
Joined: Fri Dec 07, 2012 11:34 pm

Full name search action?

Post by luckylindy » Fri Jul 04, 2014 11:58 pm

Been a longtime Launchbar user; no computer I've owned is complete without it. I've always had one gripe, though: Launchbar does not let me enter the full name of, say, a folder, a file or a person (because it contains spaces.) I'm not the only one who finds this to be a burdensome omission (see this post http://forums.obdev.at/viewtopic.php?f=4&t=4683&p=15361&hilit=complete+file+name+full+name+#p15361).

So, I'm wondering if it's possible to create an action that will let me enter said full name and then it searches LB's index to open the item in question? The way the built-in Google action works, only for local items. Anyone know of such an action? Any other suggestions for this functionality (maybe it is one of the LB myriad options I always seem to discover.)

In some future version, it might be nice to have an assignable alternative to the spacebar in LB prefs -- for example, the option key, or something-spacebar -- so that I can then type full name into LB.

Thanks.

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

Re: Full name search action?

Post by iRounak » Sat Jul 05, 2014 4:07 am

I really don't understand what the problem is in this case. Please care to explain me again because I don't get it.
In my case,

I type
gc
and I get
4 Girl Chair Trick! [720p].mp4

stju
gives
GTA 5 Stunt Jump Locations 1-25 - Show Off Achievement - Gra.mp4

rament
gives
Ramesh Ent (Pune)

If you just want to press spacebar out of habit then use this: (searches Spotlight, not your LB index)

Code: Select all

on handle_string(thequery)
   
   try
      set tid to AppleScript's text item delimiters
      set AppleScript's text item delimiters to " "
      set theCount to count of text items in thequery
      set theList to text items of thequery
      set theList2 to {}
      repeat with i from 1 to theCount
         set end of theList2 to (text item i of theList & "*")
      end repeat
      set thequery to theList2 as text
      set AppleScript's text item delimiters to tid
      set thecmd to "mdfind  'kMDItemDisplayName == " & quote & thequery & quote & "wc" & " '"
      set theresult to do shell script thecmd
      set theList to {}
      set allparas to every paragraph in theresult
      repeat with apara in allparas
         set end of theList to (POSIX file apara) as alias
      end repeat
      if theList is {} then
         set theList to "No items were found for " & thequery
         tell application "LaunchBar"
            remain active
            set selection to theList
         end tell
         exit repeat
      end if
      
      tell application "LaunchBar"
         remain active
         set selection to theList
         if (count of theList) is not 1 then
            tell application "System Events"
               tell process "LaunchBar"
                  keystroke space
               end tell
            end tell
         end if
      end tell
   on error e
      tell me to activate
      display dialog e
   end try
end handle_string

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

Re: Full name search action?

Post by iRounak » Sat Jul 05, 2014 4:46 am

Sorry for so many edits. No more now.

Allsop
Rank 1
Rank 1
Posts: 30
Joined: Mon Oct 21, 2013 8:46 pm

Re: Full name search action?

Post by Allsop » Sat Jul 05, 2014 6:34 am

I think what the OP means is that it is not possible to enter something like “Andrew Allsop” (without parentheses) or even “Stuff to sort” which is a folder of mine. It is the spaces that are the problem. I agree that this an irritation at times.

Jono
Rank 4
Rank 4
Posts: 161
Joined: Mon Feb 25, 2008 11:25 am
Location: UK
Contact:

Re: Full name search action?

Post by Jono » Sat Jul 05, 2014 7:00 am

I know exactly what you mean.

I've used LaunchBar for years and always disliked this about the app, and still can't get used to it. I still forget and enter spaces when tying to search for something.

I've come to the conclusion that it's really good for abbreviated search (launching), typing a few letters for things you know the name of and open often (apps, folders etc.), but not for searching. For general searches something like iRounak's Spotlight search script is better. I hope they'll add more (official) Spotlight search functionality to the app in the future.

Allsop
Rank 1
Rank 1
Posts: 30
Joined: Mon Oct 21, 2013 8:46 pm

Re: Full name search action?

Post by Allsop » Sat Jul 05, 2014 1:09 pm

Jono wrote:I know exactly what you mean.

I've used LaunchBar for years and always disliked this about the app, and still can't get used to it. I still forget and enter spaces when tying to search for something.

I've come to the conclusion that it's really good for abbreviated search (launching), typing a few letters for things you know the name of and open often (apps, folders etc.), but not for searching. For general searches something like iRounak's Spotlight search script is better. I hope they'll add more (official) Spotlight search functionality to the app in the future.

Yes there are certainly some great search engines out there for use on computer systems, I do not want to advertise any particular one, but I definitley have mine and I guess everyone should have one in their arsenal. I guess thr “best” way is to resort to good old fashioned aliases in the Dock!

luckylindy
Posts: 5
Joined: Fri Dec 07, 2012 11:34 pm

Re: Full name search action?

Post by luckylindy » Sat Jul 05, 2014 2:44 pm

Hi, all. Thanks for your input so far. Allsop hit it on the head; THAT is my frustration. And, of course, I know about Spotlight....that's why I use LB! :-) I'd like to stay in my search tool of choice....so unless someone can write an Action for this, or OD builds this into LB, we'll continue to love our beloved LB...just a little less.

Allsop
Rank 1
Rank 1
Posts: 30
Joined: Mon Oct 21, 2013 8:46 pm

Re: Full name search action?

Post by Allsop » Sat Jul 05, 2014 3:22 pm

One, (still unsatisfactory IMHO) answer I suppose is to have file names without spaces! :roll:

Allsop
Rank 1
Rank 1
Posts: 30
Joined: Mon Oct 21, 2013 8:46 pm

Re: Full name search action?

Post by Allsop » Sat Jul 05, 2014 3:39 pm

Okay, I have found a more satisfactory answer, and here I am, despite my earlier post, going to mention my search engine— it is EasyFind, (I am not connected in any way to the developers of this product). After entering my shortcut for EasyFind in LB I hit spacebar and then type the target name to initiate a search. Still not as good as being able to type the target directly into LB, but better than my rather ironical last suggestion!

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

Re: Full name search action?

Post by iRounak » Sat Jul 05, 2014 6:38 pm

luckylindy wrote:Hi, all. Thanks for your input so far. Allsop hit it on the head; THAT is my frustration.

Sorry, I still don't get it. Can someone explain me with examples?

And, of course, I know about Spotlight....that's why I use LB! :-) I'd like to stay in my search tool of choice....so unless someone can write an Action for this, or OD builds this into LB, we'll continue to love our beloved LB...just a little less.

The script I wrote above allows you to type “Andrew Allsop” (without parentheses) or even “Stuff to sort” (Infact, if you type "s t s", you are very likely to find "Stuff to sort" in your first few results).

Sorry again, if my comments are not making any sense.

Cabinda
Posts: 5
Joined: Tue Jun 17, 2014 7:34 pm

Re: Full name search action?

Post by Cabinda » Sun Jul 06, 2014 3:56 pm

iRounak wrote:
luckylindy wrote:THAT is my frustration.

Sorry, I still don't get it. Can someone explain me with examples?

Every single app and every single website accepts spaces in searches, LaunchBar is the only one not accepting spaces. That is a frustration for most users. I am sure you understand (even if you claim you don't). The initials trick that you mentionned is useful for launching, but completely useless for searching. When you search for a file, you don't know its full name yet, let alone its initials. You don't use initials for searching, you use keywords, and nothing is more natural than to separate those keywords with a space.

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

Re: Full name search action?

Post by iRounak » Sun Jul 06, 2014 4:23 pm

Every single app and every single website accepts spaces in searches, LaunchBar is the only one not accepting spaces.

Prefix it with AFAIK

That is a frustration for most users. I am sure you understand (even if you claim you don't).

I used Quicksilver for like three years and been using LB for like 5 years and I never even knew that this was a problem for some (or many) till this thread. I am not associated with the developers, so there is no reason for you to say this. In fact, I also get annoyed by many things in LB including the half-baked extensions implemented in LB6.

The initials trick that you mentionned is useful for launching, but completely useless for searching. When you search for a file, you don't know its full name yet, let alone its initials. You don't use initials for searching, you use keywords, and nothing is more natural than to separate those keywords with a space.


An applescript for a missing feature may not be as good as an actual implementation. But that is the best one can do till the feature gets implemented. This is the view with which I write applescripts.

If you want to use keywords instead of initials, you can use the script posted below. Since you stress on searching files which you have little memory of, I have made this script very flexible:
If you wanted to search
4 Girl Chair Trick! [720p].mp4
you can type
chair
or
trick
or
chair trick
or
girl trick
or even
hair trick

I suggest you just glance at the flexibility provided by mdfind in the image below though you many not want to script anything (or use any script for that matter).

Screen Shot 2014-07-06 at 7.49.38 pm.png
Screen Shot 2014-07-06 at 7.49.38 pm.png (127.61 KiB) Viewed 5266 times


Code: Select all

on handle_string(thequery)
   
   try
      set tid to AppleScript's text item delimiters
      set AppleScript's text item delimiters to " "
      set theCount to count of text items in thequery
      set theList to text items of thequery
      set theList2 to {}
      repeat with i from 1 to theCount
         set end of theList2 to (text item i of theList & "*")
      end repeat
      set thequery to theList2 as text
      set AppleScript's text item delimiters to tid
      set thecmd to "mdfind  'kMDItemDisplayName == " & quote & "*" & thequery & quote & "wc" & " '"
      set theresult to do shell script thecmd
      set theList to {}
      set allparas to every paragraph in theresult
      repeat with apara in allparas
         set end of theList to (POSIX file apara) as alias
      end repeat
      if theList is {} then
         set theList to "No items were found for " & thequery
         tell application "LaunchBar"
            remain active
            set selection to theList
         end tell
         exit repeat
      end if
      
      tell application "LaunchBar"
         remain active
         set selection to theList
         if (count of theList) is not 1 then
            tell application "System Events"
               tell process "LaunchBar"
                  keystroke space
               end tell
            end tell
         end if
      end tell
   on error e
      tell me to activate
      display dialog e
   end try
end handle_string

Cabinda
Posts: 5
Joined: Tue Jun 17, 2014 7:34 pm

Re: Full name search action?

Post by Cabinda » Sun Jul 06, 2014 4:56 pm

iRounak wrote:I used Quicksilver for like three years and been using LB for like 5 years and I never even knew that this was a problem for some (or many) till this thread. I am not associated with the developers, so there is no reason for you to say this. In fact, I also get annoyed by many things in LB including the half-baked extensions implemented in LB6.

Sorry if I aimed my arguments against you. I have around 20.000 documents and folders that I work with daily, and the space behaviour in LaunchBar is driving me nuts. I sincerely thought that you were pretending when you said "I don't get it". Anyway, thank you for the explanations and the scripts!

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

Re: Full name search action?

Post by iRounak » Sun Jul 06, 2014 5:18 pm

yw

Jono
Rank 4
Rank 4
Posts: 161
Joined: Mon Feb 25, 2008 11:25 am
Location: UK
Contact:

Re: Full name search action?

Post by Jono » Mon Jul 07, 2014 12:54 pm

iRounak wrote:

Code: Select all

on handle_string(thequery)
   
   try
      set tid to AppleScript's text item delimiters
      set AppleScript's text item delimiters to " "
      set theCount to count of text items in thequery
      set theList to text items of thequery
      set theList2 to {}
      repeat with i from 1 to theCount
         set end of theList2 to (text item i of theList & "*")
      end repeat
      set thequery to theList2 as text
      set AppleScript's text item delimiters to tid
      set thecmd to "mdfind  'kMDItemDisplayName == " & quote & "*" & thequery & quote & "wc" & " '"
      set theresult to do shell script thecmd
      set theList to {}
      set allparas to every paragraph in theresult
      repeat with apara in allparas
         set end of theList to (POSIX file apara) as alias
      end repeat
      if theList is {} then
         set theList to "No items were found for " & thequery
         tell application "LaunchBar"
            remain active
            set selection to theList
         end tell
         exit repeat
      end if
      
      tell application "LaunchBar"
         remain active
         set selection to theList
         if (count of theList) is not 1 then
            tell application "System Events"
               tell process "LaunchBar"
                  keystroke space
               end tell
            end tell
         end if
      end tell
   on error e
      tell me to activate
      display dialog e
   end try
end handle_string


The script here is slightly different to the one you posted here (ignoring the fact that the other one was just for searching folders).

I don't know much AppleScript, is this one better? If it is I'll use this one (what does the extra code do?).

Post Reply