JolinM Posted October 31, 2023 Share Posted October 31, 2023 Hi all, I tried building an Automator or Shortcut or Alfred workflow and failed each time đ.  My goal: 1. convert images to TIFF 2. change the resolution of the TIF to 300 DPI (either with sips or imageprep [?]) 3. move source file in a subfolder called Archive.  I'm able to do step 1/2 with this shell script imageprep -r 300 -f tif  But I donât know how to do the rest⊠and / or get the selected files in the folder. I also tried building a workflow with Alfred Automations⊠ I think I'm turning in circle in my living room now. Any insight would be appreciated! đ Link to comment
Stephen_C Posted October 31, 2023 Share Posted October 31, 2023 On the assumption you're using a Universal Action to select the files in the first place it's actually reasonably easy to do what you wish. It's probably easiest if I point you to a workflow on the Alfred Gallery which should help with your programming. (Full disclosure: I wrote the workflow.) Â Take a look at my Move to new folder workflow. You should be able fairly easily to adapt pieces of that. If your Archive folder is in the same location every time you use your workflow you can adapt the workflow so as not to prompt for the folder location each time, of course. Â By all means post again if you still have problems. Â Stephen Link to comment
JolinM Posted October 31, 2023 Author Share Posted October 31, 2023 Hi @Stephen_C, thanks for the help, I can definatelly build on this! Â That being said, I still don't know how to run my imagepre shell script with success in Alfred (or Shortcut or Illustrator). Â Best, Link to comment
Stephen_C Posted October 31, 2023 Share Posted October 31, 2023 (edited) 34 minutes ago, JolinM said: I still don't know how to run my imagepre shell script with success in Alfred You should be able to do that by linking your keyword to an Alfred Run Script action and then proceed from there. See here for Alfred help on reading environment variables (which will help you feeding the files into your script). Â Stephen Edited October 31, 2023 by Stephen_C Link to comment
JolinM Posted January 10 Author Share Posted January 10 I finally finished this quite simple workflow. Thanks for the guidance @Stephen_C. Here's the final product. Link to comment
Stephen_C Posted January 10 Share Posted January 10 Well done! Now see if you can cater for others whose path to the Desktop (and user name) is not the same as yours. By way of a hint, take a look at the workflow configuration in, for example, my Save 'ur note workflow. The workflow configuration can be a great help for users. For example, you could mention in it the need to download and install imageprep and provide a link to the download. Take a look at this Alfred help page about workflow configuration. Â (I should say that I've not run the workflowâalthough I downloaded and looked at itâbecause I have neither tiffs nor imageprep. However, I'm sure you've checked that it works!) Â Stephen vitor 1 Link to comment
JolinM Posted January 11 Author Share Posted January 11 HI @Stephen_C, didn't think of that, but it is all good recommendation. Will go back to refining it a bit. Stay tuned. Link to comment
JolinM Posted January 11 Author Share Posted January 11 Almost there! I now have a configuration page + requirement. Only thing I still can't figure is how to loop my script for each selected file. Should that be done with a Split Arg Utility? My current selection from the Finder is formatted like this: "/Users/jolinmasson/Desktop/photo 1.jpg", "/Users/jolinmasson/Desktop/photo 2.jpg", "/Users/jolinmasson/Desktop/photo 3.jpg" Â Link to comment
Stephen_C Posted January 11 Share Posted January 11 Sorry to keep directing you to my own workflows but it's easier than trying to describe here the detail of what you need to do. Take a look at Shrink JPEG/PNG Files on the Alfred gallery. The workflow is quite clearly annotated so you'll be able to work out how it deals with more than one selected file. Â Stephen Link to comment
JolinM Posted January 11 Author Share Posted January 11 Working by examples and reverse engineering existing workflows is really great, help's a lot! In this case, your workflow seems to be a File Action. As mine start with a Keyword + Finder section, I'm struggling to connect the right thing. Here's where I'm at. Really appreciate the help btw! Â Link to comment
Stephen_C Posted January 12 Share Posted January 12 I'm rather short of time just at the moment so I'm sorry if this response is not as helpful as it might be. My quick comments are: I would definitely start with a Universal or File Action for a workflow like this (although you can clearly use a keyword if you really prefer to do so). Generally, you need to review how parameters are passed to a shell scriptâbecause you're trying potentially to pass more than one parameter (i.e., file name) but have provided (I think, with the incorrect syntax) for only one. You may also need to check how imageprep deals with multiple parameters (although I can't imagine that would differ from any command line tool). Apologies for not being more helpful: have to dash off to swim! đ Â Stephen Link to comment
Stephen_C Posted January 12 Share Posted January 12 OK, now, rather more helpfully (I hope!)⊠ First take a look at something like this page about using command line variables, so that you get the general idea: How to Use Command Line Arguments in a Bash Script.  Next, bear in mind you're not going to know, when using the workflow, whether you have only one, or more than one, file selected. That means you're going to need something like this in your shell script: for var in "$@" do [your relevant imageprep command substituting "$varâ, quoted like that, for your variable in the shell command] done  In passing, you've probably not chosen the easiest start to learning workflowsâbut that's the way we all learn!  Stephen Link to comment
JolinM Posted January 12 Author Share Posted January 12 Amazing! Did exactly that, and it works! I updated my post here. Let me know if you have any suggestion to improve it đ Link to comment
Stephen_C Posted January 12 Share Posted January 12 Well done! The only thing I would do (and it's purely a personal preference) is to add, after the shell script, a notification action confirming conversion of the file(s)and the file's/files' location. Note that you can use {var:destinationFolder} in the notification so that it shows the correct destination folder configured by the user. Â I like that sort of notification because it reassures the user that something has actually happened and reminds the user where what has happened can be found! Â Stephen Link to comment
JolinM Posted January 12 Author Share Posted January 12 Good idea; done! Thanks again for all the support. Hope the swim was nice đ Stephen_C 1 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