nikivi Posted March 8, 2017 Share Posted March 8, 2017 (edited) I had an issue with a workflow I made where I need to capture a query made to a file filter. That is I activate a file filter and type something and get some files as result : I wish I could save this 'alfred' word into clipboard so that I can then use it later. I have started a thread with this issue here (https://www.alfredforum.com/topic/10086-how-to-capture-query-made-in-a-file-filter/?do=findComment&comment=50828) but no one could give a solution to it so I assume the only choice is to make a file filter of my own but I doubt I can make it as fast as Alfred's. Edited March 8, 2017 by nikivi Link to comment Share on other sites More sharing options...
nikivi Posted March 9, 2017 Author Share Posted March 9, 2017 Can someone guide me in a direction in which I can write my own file filter? It seems really silly that there seems to be no way to get a word query from a file filter. Link to comment Share on other sites More sharing options...
dfay Posted March 11, 2017 Share Posted March 11, 2017 (edited) what are you trying to accomplish? The answer is right there in the other thread, pipe it to the clipboard. Or just hit command-A command-C and copy it. Or if you really don't want it on the clipboard, you can write it to a file. But I'd recommend just using the clipboard and your clipboard history (in Alfred or elsewhere -- I prefer Copied). If you're looking for an example of a script filter that produces an actionable list of files, see Edited March 11, 2017 by dfay Link to comment Share on other sites More sharing options...
nikivi Posted March 11, 2017 Author Share Posted March 11, 2017 (edited) Hey @dfay, what do I pipe to the clipboard? What input goes into the file filter, the only thing that comes out is a path of a file. I have a file filter that allows me to search through all of my MindNode files and gives a dynamic list of files that have the {query} in them. Like so : After the file filter I can copy the output to the clipboard, but that output is a path that corresponds to a file. I need the words query I typed, 'script filter' in this case. I can create an intermediary empty keyword trigger, get the query, pipe it to clipboard and then pipe it to the file filter but that is really bad as I want to see files for what query that I type immediately. I hope this clears up what it is I want to achieve. And I did look into @vitor's script, but I thought it just watches a folder for files. It does't really do what I want and also it's a bit slower on startup. I am sure it should be possible to get this word query from the file filter, I can see many use cases where one can need it. Oh, and selecting my query and copying it before actioning on a file does work, the problem is that I use this action very often and it is very annoying to have to do this every time. Here (https://transfer.sh/132YYB/search-for-content.alfredworkflow) is the workflow. Edited March 11, 2017 by nikivi Link to comment Share on other sites More sharing options...
dfay Posted March 12, 2017 Share Posted March 12, 2017 OK I see what you're saying. You want to act on the selected text but perhaps change the query later and have save the changed query. You're going to have to write a custom script filter that saves the query in a file every time and then runs the search. Running the search is pretty easy -- you can do it in bash using mdfind (the command-line interface for Spotlight) and it should be blazing fast since Spotlight does the heavy lifting. mdfind 'kMDItemTextContent == "*{query}*" && kMDItemContentType = "com.mindnode.mindnode.mindmap"' -onlyin ~/Library/Mobile\ Documents/W6L39UYL6Z~com~mindnode~MindNode/Documents That will return a list of results. You just need to hook it together with the programming language and Alfred workflow library of your choice Link to comment Share on other sites More sharing options...
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