Jump to content

Search file by name and content

Recommended Posts

You can configure a File Filter to search both name and content.

But AFAIK, it's not actually possible to specify fields in your query (e.g. name:Activity.java Hat) like you can in Finder.

Share this post

Link to post

I'm trying to configure a file filter workflow to search both in the filename and it's content. However I don't seen to be getting the correct results.


I have a markdown file named "stats - moments.md" with the string "=todo" inside it. When I search for either "stats" or "=todo", I got the expected results. However, when I search for "stats =todo" I don't get any results back. Is this the intended behaviour?


I've posted what I hope is a reproducible example on github with the search scope set to `~/afred-reprex`.

Share this post

Link to post
Posted (edited)

Hi @fjuniorr, welcome to the forum. Great description of your issue.


On 3/9/2019 at 11:33 PM, fjuniorr said:

Is this the intended behaviour?


Unfortunately, yes. From your screenshot:



Note that {query} values are OR'ed together, string constant values are AND'ed together.







Edited by deanishe

Share this post

Link to post

@deanishe @fjuniorr Ello! :)


By default, what's happening is that both words "stats" and "=todo" are being searched for in both fields; You don't get a result because both words aren't found in the title and both words aren't found in the content.


Here's a workflow that allows you to search by entering part of the title, then some content to return results.


Here's the download link:

https://www.dropbox.com/s/6yaqeg8koglpxae/Search File Name then Content.alfredworkflow?dl=0


Taking a look at this example, you would type the keyword "fname" followed by the file name, hit return then enter some of the content to see your results returned in-line.


You'll notice the Metadata fields are empty in the file filter; The JSON object is used to dynamically set these based on your input from the first keyword.


It's not possible to currently put variables into the File Filter's metadata fields, but that's something we're aware of and is on our list of considerations :) Let me know how you get on.



Share this post

Link to post

Thank you very much for this workflow!


The problem that still remains for my use case is that I don't know in advance where the words will appear (ie. it might be the case that both words only occur in the file content, instead of "stats" in the filename and "=todo" in the file content) and therefore can't use this type of dynamic filter.


But again, thanks for the help and attention.



Share this post

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.

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...