Pass multiple variables to a script

shellscript
variables

#1

Hi!

I’ve just started with Keyboard Maestro a week ago but I absolutely love it. Tons of things to learn. I am currently hitting a wall creating a macro that multiple variables need to be passed.

The content of the macro

I want to use ImageMagick command tool to create a collage from selected images.

The command used here is

montage image1.jpg image2.jpg -geometry 800X800+25+25 -density 300 -quality 100 converted-image.jpg  

Ideally I want to be able to handle not only two images, but any amount of images selected, to pick every image’s path and put them between “montage” and “-geometry”

What I currently have

minipost%20image%20montage-pty

I searched both wiki and google, but could not find the method to pass multiple variables.

When I tried to run shell script with plain text, it seems like KM was not picking up the path. So I thought of store every path into the clipboard and paste them in the reverse order in order to pass the variables. I currently set the macro to paste last two paths, but have no idea how this would work for any amount of images.

I must’ve done something wrong as the script would not work. The macro always got canceled.

To test if the variables are correct, I added a text box to display them.

I paste the text into iTerm and it worked.

I realize I probably cannot use user input as the final file name, but it did not make any difference when I used a pre-defined name.

I appreciate any feedback or help :sparkling_heart:


#2

Maybe a stupid question, but if the montage binary is in /usr/local/bin, why not just call it as:

/usr/local/bin/montage

instead of:

montage

And here is a simpler way to get a space delimited list from the finder's selection:

image


#3

Maybe this will help. Where I used text input, you can use KM Variable tokens, like:
%Variable%image1%