calebaharrison Posted May 18, 2016 Posted May 18, 2016 (edited) 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: Filter file types (e.g. search only PDFs or only .skim notes or only .mmd files) Search for text within files of that type (e.g. search for 'justice' within only PDFs, or within only .skim notes) (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 May 19, 2016 by calebaharrison
Vero Posted May 18, 2016 Posted May 18, 2016 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
dfay Posted May 19, 2016 Posted May 19, 2016 (edited) 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 May 19, 2016 by dfay
deanishe Posted May 20, 2016 Posted May 20, 2016 From my tests, it appears that Alfred doesn't expand (query), {query} or {var:…} macros in the "fields" object. A bug?
calebaharrison Posted May 24, 2016 Author Posted May 24, 2016 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.
Andrew Posted May 26, 2016 Posted May 26, 2016 Could you update to the latest 3.0.1 b656 pre-release build in Alfred's Update prefs, this should be fixed now
dfay Posted May 26, 2016 Posted May 26, 2016 Yep, working now, thanks! Doing the Boolean searches from Caleb's original request is going to be more of a challenge....
johseb Posted May 22, 2017 Posted May 22, 2017 (edited) 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 May 23, 2017 by johseb
evanfuchs Posted June 24, 2017 Posted June 24, 2017 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.
GuiB Posted August 12, 2017 Posted August 12, 2017 (edited) @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 August 12, 2017 by GuiB
Andrew Posted August 14, 2017 Posted August 14, 2017 @GuiB thanks for the workflow, I'll take a look into this once I finish what I'm working on and get back to you
Andrew Posted August 16, 2017 Posted August 16, 2017 @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]
GuiB Posted August 16, 2017 Posted August 16, 2017 Great @Andrew ! I'm glad my workflow was helpful! I think I remember having difficulties with some other fields from other objects, so this should be the same thing! Looking forward for the bug fix! Thanks again!
Andrew Posted August 16, 2017 Posted August 16, 2017 @GuiB This is dealt with by Alfred's workflow framework code, so hopefully fixing arrays / complex arrays for this case will also fix any other areas which weren't working GuiB 1
Andrew Posted September 4, 2017 Posted September 4, 2017 @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
GuiB Posted September 4, 2017 Posted September 4, 2017 Yes, things seems to work great after some testing by configuring the File Filter object using the JSON object before! Again, thanks @Andrew! Andrew 1
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