Jump to content

Searching for phrases in files


Recommended Posts

Sorry, guys. I'm sure this is a dumb question, and I'm sure the answer is obvious, but I'm new to Alfred and I can't seem to get it to cope with spaces when searching in documents. I want to be able to search for all files containing a given phrase (eg. "albert version 2"). However, I can't stop it treating each word separately and thus giving me all files that contain either "albert" or "version" or "2". With spotlight, I can put the phrase in quotes - but this doesn't seem to work in Alfred.

 

Any help would be much appreciated!

 

Thanks!

Jonathan

Link to post

Sorry, guys. I'm sure this is a dumb question, and I'm sure the answer is obvious, but I'm new to Alfred and I can't seem to get it to cope with spaces when searching in documents. I want to be able to search for all files containing a given phrase (eg. "albert version 2"). However, I can't stop it treating each word separately and thus giving me all files that contain either "albert" or "version" or "2". With spotlight, I can put the phrase in quotes - but this doesn't seem to work in Alfred.

 

Any help would be much appreciated!

 

Thanks!

Jonathan

 

Hi Jonathan, to search inside files, prefix your search term with "in". This keyword searches inside files, allowing you to find files by content.

 

Here's more information on Alfred's main few keywords for file search:

http://support.alfredapp.com/features:file-search#feature

 

If you're frequently searching for particular files or content, you may want to take a look at File Filters, which allow you to create your own keywords to search pre-set folders or file types. Here's a tutorial for this:

http://support.alfredapp.com/tutorials:file-filter-workflow

 

Cheers :)

Vero

Link to post

Thanks, Vero. Yes, I found the "in" keyword and that works fine in that I can type "in wet weather" and I will get files that contain the word "wet" and I will get files that contain the word "weather". However, what I need is only those files with the phrase "wet weather". It is that I can't seem to do as the space is treated as a separator rather than as part of the search string. As I said earlier, when using Spotlight I could always put my search string in quotes and it would work, but Albert seems to treat the quotes differently.

 

Thank you, too, for the pointer towards the workflows. I did try and see if I could get something to work that way, but still without success. I searched the kMDItemTextContent field for the query field and tried unticking Split - but no joy. In fact, it then failed to find anything at all unless I entered a single word.

Link to post

Thanks, Vero. Yes, I found the "in" keyword and that works fine in that I can type "in wet weather" and I will get files that contain the word "wet" and I will get files that contain the word "weather". However, what I need is only those files with the phrase "wet weather". It is that I can't seem to do as the space is treated as a separator rather than as part of the search string. As I said earlier, when using Spotlight I could always put my search string in quotes and it would work, but Albert seems to treat the quotes differently.

 

Thank you, too, for the pointer towards the workflows. I did try and see if I could get something to work that way, but still without success. I searched the kMDItemTextContent field for the query field and tried unticking Split - but no joy. In fact, it then failed to find anything at all unless I entered a single word.

 

I don't know about "Albert", but Alfred should find the results ;)

 

To be found with the "in" keyword, a file has to be:

- within the search scope in Features > Default Results

- a file type you've chosen to show in Features > File Search

- indexed correctly by OS X

 

By default, this covers most files on your Mac, but if it's in an unusual place, it might not be included in the default scope. If the file you're searching for is not within the scope, drag the appropriate enclosing folders to add them. Can you find the file if you type "open" followed by the file name?

 

As for workflows, if you give me an example of file types you want to search and where these files are located (e.g. somewhere in your Documents folder), I'll be happy to help you create a file filter workflow :)

Link to post

Alfred!  Names were never my strong point!  :)

 

Sorry, I'm obviously not making myself clear. Alfred has no problem in finding the files. I just want to be able to do the same as I can with Spotlight and include spaces in my search string.

 

Alfred should be able to do exactly what you are saying. As an example, I made 3 sample files..

 

temp1.txt -> content is "wet"

temp2.txt -> content is "weather"

temp3.txt -> content is "wet weather"

 

Using the 'in' keyword as Vero suggested to search for 'in wet weather' only returns temp3.txt as a result.

Link to post

Alfred!  Names were never my strong point!  :)

 

Sorry, I'm obviously not making myself clear. Alfred has no problem in finding the files. I just want to be able to do the same as I can with Spotlight and include spaces in my search string.

 

Ok, if I understand correctly, you want to be able to find a phrase like "wet weather" but not a file that happens to contain "wet" and "weather" as separate words.

 

To do this, create a simple workflow with a "file filter" input attached to an "open file" action. Double-click your file filter and give it a name and keyword, then go to the Advanced tab. Click the + and add the kMDItemTextContent and uncheck the "split" box. Remove the other fields from the list.

 

This will be a file filter that exclusively searches content of your files (not the file names) and specifically searches for concurrent words, e.g. a file that contains "wet weather" but not "wet" and "weather" as separate words in the file. 

 

Is this what you were looking for? :)

Link to post

Thanks, guys. It is encouraging to know that it is indeed supposed to work like that. Unfortunately, it is still not currently working on my machine. Having said that, my Smart Mailboxes have stopped working correctly and one or two other things are a bit suspect, so it may be that my Spotlight database has become corrupted in some way. I'll try and sort that out first and then see if that fixes the problem.

 

Many thanks for your help!

 

Jonathan

Link to post
  • 3 years later...
On 8/27/2014 at 3:38 AM, Vero said:

To do this, create a simple workflow with a "file filter" input attached to an "open file" action. Double-click your file filter and give it a name and keyword, then go to the Advanced tab. Click the + and add the kMDItemTextContent and uncheck the "split" box. Remove the other fields from the list.

 

This will be a file filter that exclusively searches content of your files (not the file names) and specifically searches for concurrent words, e.g. a file that contains "wet weather" but not "wet" and "weather" as separate words in the file. 

 

Is this what you were looking for? :)

 

This is an oldie, but I dug it up on search. When I set up a file filter this way it does not find the matching phrase. And if I check "split", I get extraneous results matching each word of the phrase (as I believe is expected, just as I do using the built-in "in" command). Is this still the preferred way to find exact phrases in file content? Help? :)

 

Edit: I should add that spotlight appears to match only the exact phrase, so I'm guessing that means indexing is good if that helps.

Edited by evanfuchs
Link to post
  • 10 months later...

 

Jonathan11 asked a perfectly clear question.  I don't know why nobody can answer it.  If you type "in wet weather" he expects Alfred to find files containing the exact phrase "wet weather".  

 

Unfortunately Alfred would also find a file with phrase "Today's weather is wet".  

 

There does not seem to be any way that I can find to have Alfred search for the exact phrase

 

 

 

 

 

--

 

 

 

 

 

 

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...