Danran Posted September 13, 2023 Posted September 13, 2023 I have the unix command that is meant to recursively search by filename extension for all files in the current directory. The syntax for my command snippet is: find . -type f -name '*.file_extension_to_search_for' The actual command snippet I have written in Alfred is: find . -type f -name '*.filext' Each time I use that alfred snippet, I have to manually erase "filext" in that snippet, and re-enter my desired file extension so the final command looks more like this: find . -type f -name '*.jpg' What I desire, is for alfred to prompt me and ask me to manually enter the fileextension that i desire, and then insert that in replace of "filext", and then print the full command with the .jpg filext already entered. How can I go about doing this?
Stephen_C Posted September 13, 2023 Posted September 13, 2023 You need: to tell Alfred which folder to search (Alfred's "current folder” may not be what you expect it to be); to pass a variable (containing the file extension) to your script; and to concatenate the result of the command in some way so that Alfred can display it. This works for me—although I've no doubt it could be far more sophisticated given time and greater intelligence. 😀 Set up a keyword input to specify the keyword you want to trigger the workflow (and set with Argument Required). Connect that to your script but (initially at least) amend the script to look like this: cd ~/Downloads ls| find . -type f -name '*.'$1 Connect that in turn to a Large Type Workflow Output so that you can see the results in Alfred to prove that it works. What you'll probably need to do after that is to resolve the "current folder” problem. In that context take a look, on the Alfred gallery, at the Dynamic File Search workflow—which will show how to specify the initial search folder. By all means ask again if any of this is not as clear as it might be! Stephen
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