themanuel Posted July 7, 2013 Share Posted July 7, 2013 Hey folks!Since I'm not a pythonista it's neccessary to ask you for some help. I tried to create a workflow that simply does the following: Search in a given textfile for {query} -> extract the matching lines -> save matching lines in a textfile named results.txt That's basically it. I found a python recipe which is relevant but I couldn't figure out how to adapt it for a workflow in Alfred. I'm thankful for any help on that. Cheers! Link to comment
vitor Posted July 7, 2013 Share Posted July 7, 2013 Since I'm not a pythonista it's neccessary to ask you for some help. I’ve seen this misconception a number of times already, so I’d like to first clear that you do not need to make your workflows in python. Realistically, I often find simple (about 5 or 6 lines) python scripts that could be accomplished just as well with bash (and the tools that come with the OS) in just one line (which is the case here). The code you want for this is grep '{query}' FILE_TO_SEARCH.txt > FILE_TO_OUTPUT.txt How you implement it in Alfred, however, depends on your exact needs. How would you prefer this to accomplished, would a File Action that always outputs to the same file (say, on your Desktop), suffice? If yes, then try this quick test (link available for seven days). You use it as a file action on any file, and it’ll show a window asking for the string to search (don’t mind the text that’s already there, it won’t interfere, and it’s needed for Alfred to know what to do next). Let me know if it fits your needs. Link to comment
themanuel Posted July 9, 2013 Author Share Posted July 9, 2013 I’ve seen this misconception a number of times already, so I’d like to first clear that you do not need to make your workflows in python. Okay. I've just looked up "search a textfile and display search results in a new textfile" and the linked article was the most accurate result, as far as I can estimate the accuracy of an article on that topic. Let me know if it fits your needs. It just works. Thank you. I guess I am going to use it with Geektool on my desktop. Cheers! Link to comment
vitor Posted July 9, 2013 Share Posted July 9, 2013 It just works. Thank you. No problem, you should then finish it up by filling the titles and descriptions, and perhaps even adding an icon. If you need any help making a modification, let me know, but it should be straightforward to figure out what everything does. Link to comment
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