Jump to content

How to add "SEARCH in FINDER" option to fallback searches?


Recommended Posts

Currently whenever I want to search for a file on my Mac I rather do not use Alfred (which I use for EVERYTHING else) but I have to open a new finder window, hit CMD + F and type my query in the little spotlight window in Finder.

I then refine the search by adding filters.

 

I really would like to simplify this by adding a "SEARCH in FINDER" option to fallback searches (which I love and use all the time).

 

How can I add this option to fallback searches?

 

Screen Shot 2019-05-03 at 24.03.24 .jpg

Link to comment

@s95hc8 There's an even simpler way to search using Finder (Spotlight's Finder search); Go to Alfred's Advanced preferences, and have a look at the three options below the Action Modifier in the right column.

 

Alt + Return should be set to "Search with Spotlight" by default, but you can use any of these modifiers, so that you can simply hit Alt + Return on your query to launch Finder with the relevant search.

 

Screen Shot 2019-05-02 at 17.29.24.png

 

Cheers,
Vero

Link to comment

Yes, I am aware of this feature but for some reason I just cannot get this into my brain 😞

It would be just soooooo easy if I could add this function as a fallback search as these don't rely on a specific shortcut but I can just use the curser, hit enter and be done.

 

I find myself recently actually using spotlight instead as spotlight finds those finder files directly and displays them in a neat way.

 

I wish I could add "find file in finder" as another fallback search.

Link to comment
  • 3 years later...

@s95hc8 Are you still looking for a way to run a Finder fallback search?

 

I came across your post today when searching for some help with something else, and I thought you might find the following workflow helpful: 

 

https://gofile.io/d/dqJ7fx

 

It's a simplified version of a workflow that I use to run Finder searches. In the past, I used to rely on a hacky GUI based approach, but this one works a lot better. It uses the Spotlight service; so, assuming you haven't deleted it, you should be in good shape. If you're curious, it's the service that pops up when you highlight text and select Spotlight from the context menu. It also doesn't matter what the actual hotkey is for it (System Preferences > Keyboard > Shortcuts > Services > Searching > Spotlight).

 

Here's the basic setup (fallback search trigger + run script action):

 

image.png.88423d220441fa5f59aa5ea8f9c4ad3c.png

 

And, here's the key AppleScript:

 

use AppleScript version "2.4"
use framework "Foundation"
use framework "AppKit"
use scripting additions

on run argv
	set theQuery to argv as string
	set pb to current application's NSPasteboard's pasteboardWithUniqueName()
	pb's clearContents()
	pb's writeObjects:{theQuery}
	set theResult to current application's NSPerformService("SEARCH_WITH_SPOTLIGHT", pb)
	pb's types()
	set theArray to pb's readObjectsForClasses:{current application's NSString} options:(missing value)
	set theString to theArray's firstObject() as text
end run

# Adapted From: https://forum.latenightsw.com/t/nsperformservice-in-applescript/836

 

Cheers!

Link to comment

Nice share @Jasondm007. Do you have the workflow published somewhere to receive contributions? The code can be shorter, some of the lines aren’t doing anything:

 

use framework "Foundation"

on run argv
  set theQuery to argv as string
  set pb to current application's NSPasteboard's pasteboardWithUniqueName()
  pb's clearContents()
  pb's writeObjects:{theQuery}
  set theResult to current application's NSPerformService("SEARCH_WITH_SPOTLIGHT", pb)
end run

 

Edited by vitor
Link to comment
1 hour ago, vitor said:

Nice share @Jasondm007. Do you have the workflow published somewhere to receive contributions? The code can be shorter, some of the lines aren’t doing anything:

 

use framework "Foundation"

on run argv
  set theQuery to argv as string
  set pb to current application's NSPasteboard's pasteboardWithUniqueName()
  pb's clearContents()
  pb's writeObjects:{theQuery}
  set theResult to current application's NSPerformService("SEARCH_WITH_SPOTLIGHT", pb)
end run

 

 

Thanks for cleaning it up, @vitor!!

 

As for contributions, hopefully, others who find it helpful will just pay it forward. I've learned so much from this forum - especially from you, @deanishe, @GuiB, & @Andrew - that I'm happy to help where I can.

 

I should have noted this before, but for others who come across this post down the road, you can use the same approach to kick off other text-based services on your mac. Just substitute the "SEARCH_WITH_SPOTLIGHT" bit in the code above with your intended service (e.g., "Search With Google", "Look Up in Dictionary", etc.). However, sometimes it takes a little trial and error - as you may need to dig through the service's Info.plist file to find the appropriate key. For instance, in this case, you can't just use "Spotlight", you have to use "SEARCH_WITH_SPOTLIGHT".

 

FWIW: The "Jump to" option in the "Action in Alfred" action, really ought to contain all of Alfred's default actions. While the feature did not exist at the time of @s95hc8 original post, adding it would eliminate the need for this AppleScript altogether (i.e., people could just attach a fallback or anything else directly to the "Search with Finder" universal action). 

Link to comment
  • 2 months later...

Thank you for sharing this Jason. I am sure some of the Alfred power users who know their way around workflows and scripts will find this very helpful.
Unfortunately I do not understand how to set this up or use it.

It would be really really nice if such an important feature would be integrated into Alfred outright.
For example when using Alfred I have all these completely redundant (to me) search options like searching on youtube, wikipedia, duckduckgo, … all of them nicely presented with an icon and a short description and I could just scroll down with the cursor key and hit enter to use them.

The problem is … I never ever ever even once need those ever.
But I do hundreds of Finder searches on every single workday, … hundreds of them.
It would be great if I could initiate this through Alfred which I use to pretty much initiate 90% of my workflows in MacOS with.

For me the problem is that my brain just does not retain the optional modifier key finder search as described above by Vero.
It's great that this is a feature but it just does not work for me. I always forget and I keep already so many many keyboard shortcuts in my head.

I just want the finder search to be there in Alfred as it is such an important and fundamental thing to have.

Alfred has become over the years a complete spotlight replacement for me. Everything I used to do with Spotlight I do now with finder as of some added workflows that are not available in Spotlight.
Search in Finder is one of the last features Spotlight has as it is such an important and fundamental feature but it is missing in Alfred 😞

Today I finally upgraded to Alfred 5 in hopes that this would be perhaps a newly added feature 😞

That's all I want, just like in spotlight (and perhaps an option to modify which of the optional searches is presented in which order in Alfred as some may search more on the web and others perhaps more in Finder:
image.jpeg.67657ae7933056e3c420760769329b8f.jpeg

Link to comment

Sure thing, @s95hc8!

 

While there's a lot in your post, it sounds like you just need to configure your fallback searches. To learn how to do this, check out the following link:

You'll find the "Fallbacks" section down at the very bottom of Alfred's "Default Results" panel (in Alfred Preferences).

 

In short, I think you should (1) Set Alfred to "Intelligently show fallbacks at the end of results", (2) Click the "Setup fallback results" button, and then (2.A) Remove the default fallback searches you don't use, and (2.B) Add the fallback Finder search that I sent you above (if you click the plus sign, and you've installed it correctly in your workflows, you should see it under the "Workflow Trigger" dropdown menu.)

 

Hope this helps!

Edited by Jasondm007
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...