Page 1 of 1

Running ImageOptim-CLI on subfolders

PostPosted: Thu Dec 26, 2013 4:44 am
by cahuk
Could please someone help me with the following workflow:

I have my photos in a Photos folder. That folder has a subfolder with the year the photo was taken (e.g 2013). That subfolder has subfolders with the name of the events where the photos were taken. Those subfolders also contain my jpegs.

Since I use JPEGmini, I optimize all jpegs with it. Before I convert my photos from RAW to jpeg, I create a subfolder with the even's name. Then I save the converted photos (jpegs) into that subfolder.

I want the following: after the jpegs are put into the event subfolder I want to run ImageOptim-CLI which invokes JPEGmini. The syntax for ImageOptim-CLI is: imageOptim-CLI -j -d folder. How can I tell imageOptim that it executes itself on the current event subfolder? I think -d $PWD is not enough.

Thanks.

Re: Running ImageOptim-CLI on subfolders

PostPosted: Thu Dec 26, 2013 1:38 pm
by Mr_Noodle
You probably want to use 'dirname' to get the containing folder. Check the man page for it.

Re: Running ImageOptim-CLI on subfolders

PostPosted: Fri Dec 27, 2013 5:26 am
by cahuk
Thanks.

One thing: can I use nested conditions on subfolders (kind is folder and then (nested condition) if subfolder contains jpeg then run the script).