nielsk Posted January 17, 2013 Share Posted January 17, 2013 I am creating a workflow that searches sites like Google Scholar, JStor and my local Evernote database for a query. Is it possible to search somehow via spotlight as well to get all files shown that contain the query (not only in the file name but in the content, too)? What I want to do is for example a first crude search for a research topic. That shall reveal results from several web sites like Google Scholar or JStor, my Instapaper- and pinboard-account, but also results from local libraries and of course local stuff on my harddrive like my Evernote-database and of course files that Spotlight would find. Link to comment
jdfwarrior Posted January 17, 2013 Share Posted January 17, 2013 Very possible. I've done just that with my mail workflow. It uses mdfind to search the drive using Spotlights metadata and grabs the results and shows those as Alfred feedback Link to comment
nielsk Posted January 17, 2013 Author Share Posted January 17, 2013 How do you do that? I can run the mdfind via a bash-script ok. But how do I get the files as "Alfred feedback" (and what do you mean actually by that)? And I would really prefer to get those results in a finder-window to have a "static" list for being able to quicklook and open files without doing the search again. Link to comment
jdfwarrior Posted January 17, 2013 Share Posted January 17, 2013 By Alfred feedback I mean that, with Alfred 2 you now have the ability to generate results that show up in Alfred. So, as you would do a typical search in Alfred and you get the list of results, with workflows now, you can generate your own list of items to show as results and action those. To actually grab that data from mdfind for use... you would have to use some kind of script to grab the output of the mdfind command. The majority of my workflows are based on PHP. With PHP I can run system commands (mdfind) and grab that output (the list of matching files) and have them show up as results in Alfred. This feedback is XML based. See the documentation for Alfred Feedback here Link to comment
nielsk Posted January 17, 2013 Author Share Posted January 17, 2013 Ouch…that seems a bit out of reach for me and my available time >_< Let's see what I can do… :/ Link to comment
tomhunt Posted January 17, 2013 Share Posted January 17, 2013 This workflow uses mdfind and returns the results in the required format. Have a pick through and see if you can hack it for your own purposes. Look for this line for the mdfind call: $shell = "mdfind \"kMDItemDisplayName == '$search*' && kMDItemContentType == '$uti'\""; This page gave me all the info I needed for this workflow. Hopefully it will help here too. http://macdevcenter.com/pub/a/mac/2006/01/04/mdfind.html Link to comment
nielsk Posted January 18, 2013 Author Share Posted January 18, 2013 This workflow uses mdfind and returns the results in the required format. Have a pick through and see if you can hack it for your own purposes. Look for this line for the mdfind call: $shell = "mdfind \"kMDItemDisplayName == '$search*' && kMDItemContentType == '$uti'\""; This page gave me all the info I needed for this workflow. Hopefully it will help here too. http://macdevcenter.com/pub/a/mac/2006/01/04/mdfind.html I can't connect to the linked ftp-server (probably because it doesn't allow anonymous login) and a request via http gives a 404. I will have a look at the macdevcenter-link. Thanks a lot Link to comment
tomhunt Posted January 18, 2013 Share Posted January 18, 2013 my bad. copied the ftp link rather than the http link. I've edited the post as needed Link to comment
nielsk Posted January 18, 2013 Author Share Posted January 18, 2013 Yep, I know but replacing the ftp by http and removing the one / from the double-slash gives a 404 Link to comment
tomhunt Posted January 18, 2013 Share Posted January 18, 2013 Use the link above. For ease : This workflow Link to comment
nielsk Posted January 18, 2013 Author Share Posted January 18, 2013 Thanks. That's pretty much what David suggested. But unfortunately it doesn't help a lot because I cannot act on it like in the Finder (Quicklook, copy around etc.). I searched more and it seems that it is just not possible to do what I want (get a Finder-window with search results) because Spotlight is actually not Applescriptable and apparently it is not possible to get the output of mdfind into a Finder-window. There's even a tip from an Apple Product Manager floating around which "scripts" it by emulating pushing buttons m) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now