The Zsh script that I have written will expect the parent folder as a selection, and then it will recursively drill down through every product name folder, and only run montage on the contents of each mockup folder, where it deposits the B.jpg result.
zsh source:
#!/bin/zsh
PARENT="${1:a}"
# JPEG quality
QUALITY=50
PPI=300
# so this script knows where the ImageMagick montage binary is located
source ~/.zshrc
# recursively get just the folders paths (F) in the parent directory
for adir in ${PARENT}/**/(F)
do
# only perform a montage on the contents of the mockups folder(s)
# and ignore any other folder or its contents
[[ ${adir%/} = ${PARENT} || ${adir:a:t:r} != "mockups" ]] && continue
montage ${adir}[l-t].jpg -geometry +3+3 -tile 3x3 -units PixelsPerInch -density ${PPI} \
-adjoin -strip -quality ${QUALITY} -background black ${adir}/B.jpg
done
exit
AppleScript source:
use scripting additions
on run {input, parameters}
display dialog "Mockup montages complete" with title "Montage Processing"
return
end run
I have tested this in an Automator application and it works as expected. The Automator solution uses three actions in its workflow:
- Library : Files and Folders : Ask for Finder Items
- Select the parent folder
- Library : Utilities : Run Shell Script
- The previous Zsh script that processes the product mockup folders
- Library : Utilities : Run AppleScript
- A dialog letting you know that montage processing is done
When you open Automator, choose the Desktop, and then click New Document. A type of document panel will then appear and you want to choose Application, and then click Choose.
Automator will then open into a three panel presentation left to right : 1) Libraries 2) Library actions and 3) a large workflow window. You drag and drop the preceding bold named actions in order onto the workflow window.
- Ask for Finder Items
- Set the Start at: to Desktop
- Set the Type to Folder (only)
- Do not select Multiple Selection
- Run Shell Script
- Shell is /bin/zsh
- Pass input: as arguments
- This will allow the folder you selected to pass into the zsh script as $1.
- Replace all default content in the Run Shell Script window with the copy/pasted Zsh script from above that follows Zsh source in bold.
- Run AppleScript
- Replace the entire default content with the AppleScript from above that follows AppleScript source in bold
- Click the hammer icon in the Run AppleScript
- Save the Automator application to your Desktop with a meaningful name
- Quit Automator
- Double-click the Automator application on the Desktop to run it.
Looks like this when done:
