Jump to content
Eric C

How to search by tag and filename at the same time?

Recommended Posts

Posted (edited)

I'm trying to incorporate Alfred in my workflow but something I am having trouble with is combining file search with tags and filenames. Spotlight seems to have no issue with this so it feels like Alfred should be able to do it too but I can't figure it out. Anyway, here is a typical situation I am interested in solving:

 

I have a handful of files tagged `projectname`. Some of these files have the word `receipt` in the filename (e.g., `hotel receipt.pdf`). I would like to be able to open Alfred and type `tags projectname receipt` or even just `projectname receipt` and have it show me files tagged `projectname` with `receipt` in its name.

 

Is this possible?

Edited by Eric C

Share this post


Link to post
On 8/27/2019 at 12:09 PM, Eric C said:

Is this possible?

 

I don't think it is, no. Perhaps @Vero can confirm.

 

Alfred won't let you match across multiple fields (unlike Spotlight). So if you enter projectname receipt, Alfred will only show items where both words are in the tags or both are in the title. It won't show results where one word matches tags and one matches the title.

Share this post


Link to post

@Eric C Alfred constructs more specific, more accurate queries than Spotlight, but the drawback is that it's not possible to match different values across multiple fields in a single query. However, it's possible to create a workflow with multiple parts, where you first set the tag, then search within tagged items.

 

Here's a workflow for you to play with, using the keyword "ftag":

https://www.dropbox.com/s/uggoywmzxj6pllb/tag file search.alfredworkflow?dl=0

 

Type the name of your tag, hit return then type the name of the file.

 

Cheers,
Vero

Share this post


Link to post

@Eric C if you update to the 4.0.4 b1108 pre-release, I've made a tweak to allow * as the Metadata Field allowing you to do the broad style of matching across multiple metadata fields as you described.

 

Configure the file filter as follows, then you'll be able to type the file name and tags e.g. `projectname receipt`.

 

multi field file search.png

 

Let me know how you get on. I have plans on improving this further in the future :)

 

Cheers,

Andrew

 

 

Share this post


Link to post

@Andrew Thanks for making this update! It's super helpful!!

 

Quick Question: Is it searching all available metadata fields or just the usual nine fields listed in Alfred's dropdown? Thanks!

 

As for the improvements you alluded to above, is there any way this will include the ability to limit/specify the metadata fields? 😀🤞

 

Alfred rocks! Thanks again, @Andrew!

Share this post


Link to post
1 hour ago, Jasondm007 said:

Quick Question: Is it searching all available metadata fields or just the usual nine fields listed in Alfred's dropdown?

 

You can put any metadata field in that table, and some may give worse performance than others, just experiment. If you want multiple fields, just add them all manually.

 

Cheers! :) 

Share this post


Link to post
1 hour ago, Andrew said:

You can put any metadata field in that table, and some may give worse performance than others, just experiment. If you want multiple fields, just add them all manually.

 

Cheers! :) 

 

My apologies @Andrew, I should have been a little more clear.

 

I was asking whether the fantastic new * method for finding matches across multiple fields - as you've shown in the screenshot above, with the metadata field set to * - is limited to searching the nine default fields provided in the file filter or whether Alfred's actually searching all metadata fields on our system (e.g., kMDItemTextContent, kMDItemFSName, and all else)?

 

Thanks again!

Share this post


Link to post

@Jasondm007 Ah I see what you mean, actually I don't have control over this as it's just allowing you to pass * as the field in the constructed MDQuery.

 

Also, in my experience, using fields prefixed with kMDItemFS can be quite a bit slower.

Share this post


Link to post

Andrew/Vero, Great workflows. But in Andrews I can only search by tag then File name. Is there any way I can perform search w/ tag then content too (kMDItemTextContent) and even file extension/type.

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.

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