Jump to content

Dynamic / variables configuration of workflow file filters [Partly fixed 3.5 b867 pre-release]


calebaharrison

Recommended Posts

Hey Folks,

 

Sorry in advance if this isn't the place for V3 workflow tips (and sorry if discussing V3 stuff, here, before public release is poor manners!). I am trying to have the following as a workflow:

  1. Filter file types (e.g. search only PDFs or only .skim notes or only .mmd files)
  2. Search for text within files of that type (e.g. search for 'justice' within only PDFs, or within only .skim notes)
    1. ​(So long as we're talking dream workflow, here, it would also be nice to filter multiply e.g. Search only in [.skim notes] with [tag=Aristotle' AND 'Nussbaum] for [query=justice]...)

I know I can do 'in {query}' to search within files, and I know I can do file filters to search for specific file types, but I don't know how to chain the two so as to search within specific file types. I gather that Alfred V3 should be able to accomplish this (some kind of dynamic file search?), but I'm at a bit of a loss as to how to do it. Would I do a file filter, and pass off the entire result-list of files of that type to the next filter as a JSON utility? Or is this a bit outside the scope of what workflows are supposed to accomplish?

 

Thanks!

Caleb

Edited by calebaharrison
Link to comment
Share on other sites

Hey Folks,

 

 

 

Hi Caleb,

 

Take a look at the Workflows > Examples > Dynamic File Search to get started.

 

In that particular example, typing "ff" then the name of a folder will allow you to dynamically set your search scope to be only the selected folder, you can then type the name of the file you want to find. In theory, there could even be another stage where you select from a List Filter a file type to narrow your search even further.

 

Playing around with that workflow as well as the Simple To-Do list (which also uses multiple variables) will allow you to see how the variables are used dynamically.

 

As you can imagine, there's tons of documentation coming for this, as soon as Alfred 3 goes to general availability, and I expect I'll be doing more tutorials and likely videos too to help users discover these new workflow features :)

 

Have fun and let us know how your workflow creation goes!

 

Cheers,

Vero

Link to comment
Share on other sites

Hi Caleb

 

you can search a specific type of file with a File Filter by setting its file types then under the Advanced tab adding a metadata field for kMDItemTextContent -- this is the Spotlight metadata key for file contents (the default on a File Filter is to search filenames and Finder comments -- you may also want to delete these).

 

In theory (moving on to the dream workflow...) you should be able save file type and tags to a variables, then use a JSON Config to pre-populate the File Filter's type and the search terms for kMDItemUserTags but in practice this doesn't seem to work.  Here's the JSON I'm using:

{
  "alfredworkflow" : {
    "config" : {
      "types" : [
        "{var:fileType}"
      ],
      "fields" : [
        {
          "words" : true,
          "value" : "{var:theTags}",
          "split" : true,
          "not" : false,
          "field" : "kMDItemUserTags"
        },
        {
          "words" : true,
          "value" : "(query)",
          "split" : true,
          "not" : false,
          "field" : "kMDItemTextContent"
        }
      ]
    },
    "variables" : {
    }
  }
}

I've set up a notification to confirm that the variables (fileType and theTags) are set correctly heading into the File Filter, but the File Filter never produces results.  The JSON Config window says it should convert "(query)" to {query} in the File Filter, but maybe this doesn't happen.

 

Vero, any suggestions?

 

Here's the workflow-in-progress.

 

https://dl.dropboxusercontent.com/u/6601556/Alfred/filtered%20search.alfredworkflow

Edited by dfay
Link to comment
Share on other sites

Thanks for the suggestions and comments Vero, dfay, and deanishe.

 

dfay, I've been playing around with your workflow, to no avail as well. (Thanks for setting it up and sharing it!) I'll keep playing around. It would be great if this worked, as it would be a super interesting research tool.

Link to comment
Share on other sites

  • 11 months later...

Hi dfay,

is the workflow posted on 19 May 2016 working for you or did you make any changes?

 

I tried using it but it didn't work. The filtering on file type is OK (for both branches, with and without tag filtering) but the tag filtering does nothing: when filtering on the content (3rd input) I get files without the selected tag as well.

 

By the way what item shall I add to the list filter to include all file types (i.e. not filtering on types)?

 

Thanks 

Edited by johseb
Link to comment
Share on other sites

  • 1 month later...
On 5/22/2017 at 6:11 AM, johseb said:

 

The filtering on file type is OK (for both branches, with and without tag filtering) but the tag filtering does nothing: when filtering on the content (3rd input) I get files without the selected tag as well.

 

 

Same. My results are not filtered by the tag specified. I tried manually adding a static tag in the file filter (kMDItemUserTags) and it also did not work. I suspect it has something to do with "and/or", but it's over my head.

Link to comment
Share on other sites

  • 1 month later...

@Andrew, like @johseb and @evanfuchs, I'm trying to dynamically specify a tag to search using a File Filter object, but it doesn't seem to work with an environment variable. The only dynamic variable that works is {query}... but I would like to set a tag using a variable and then to use the query to filter the list of files. It seems from some post above that this has worked before, but now it doesn't seem to work. I would say this is a bug ? or am I not setting things correctly ?

 

Here is a workflow to show you using {query} as the dynamic field or using a {var:tagTitle} in the File Filter Metadata Field value or by configuring the File Filter using a JSON object. (only the first method with {query} works on my side)

 

https://nofile.io/f/PJs0zmzpFdg/File+Filter+Dynamic+Tag+-+Test.alfredworkflow

 

Using Alfred 3.4.1 Build 860

 

Thanks!

Edited by GuiB
Link to comment
Share on other sites

@GuiB just a quick update on this - I've raised an internal ticket as dynamic configuration of the 'Fields' part of the file filter needs a code update to work (looks like this has never worked). This would get the 'alt' connection path working in your example workflow. It also looks like variable replacement within [complex] config tables also aren't being correctly replaced, so I'll get that sorted too.

 

Your workflow example was completely on point btw, it makes my job significantly easier! :) 

 

Cheers,

Andrew

 

[moving to bugs]

Link to comment
Share on other sites

  • Andrew changed the title to Dynamic / variables configuration of workflow file filters [Accepted]
  • 3 weeks later...

@GuiB If you update to the 3.5 pre-release, dynamic configuration using JSON should now work (the bottom one in your example workflow). Note that you could actually get rid of the ArgVar object in that flow and put the {query} directly into the value field in your JSON Config object.

 

I still haven't gotten around to being able to use variables directly in complex tables such as the file filter fields section, but this is planned.

 

Cheers,

Andrew

Link to comment
Share on other sites

  • Andrew changed the title to Dynamic / variables configuration of workflow file filters [Partly fixed 3.5 b867 pre-release]

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