Pass multiple files in Finder Selection "At Once" to shellscript

Hi dear people in this most amazing forum,

I’ve been searching around here and on the web, but for the life of me, can’t find an answer to my problem (and i’m way out in the woods with shell scripts).

I like to make a GIF from a finder selection of multiple JPGs. I started to research, installed Imagemagick (to be able to use Convert to generate GIF) and I found this code for a shell script in automator:

/opt/local/bin/convert -delay 200 -loop 0 “$@” ~/Desktop/animated.gif

While this works fine by itself, I really want to execute it within KM itself, not by an Automator Service/ Action.

The problem is this: I can’t get multiple files (and their paths) to pass at once to the shell script…It needs multiple file input. I tried to understand the shell script but it is rather a big leap for me and will require more research/learning. I’m stumped. Can someone help me out?

I think I need to somehow:

  • generate a KM Variable (with multiple filepaths) that can be passed and read by the script?
  • It would be superb if I could also define the script output by a KM Variable, to generate the GIF at the same spot as the finder selection (or somewhere at a fixed spot)

Can someone point me in the right direction? There’s no hair left, aarrgh! :wink:
Thanx.

I am sure this is a good way to this using only the shell.

But I have previously moved all the files I need to process to temporary folder.
Then the shell command can do something like.
convert /tempfolder/*.jpg ~/Desktop/animated.gif

The above is just a pseudo example.

You can find a macro which uses this here to merge pdf-files.

Hope you can modify to your need.

1 Like

Hey!

That’s a good suggestion, never thought about that, thanx!
A good workaround I would say :slight_smile:
Though it would be nice to be able to set the input/output path via a KM Variable. Hmmm.
I tried reading the wiki on KM Variables and shell scripts but I am way over my head in this haha. Stumbling on the ENV_PATH Variable almost broke my mind :smile:
Maybe someone can chime in on this?

edit: I now see within your post the setting of KM Variables as input/output! Thanx again, I’m gonna tinker with that approach.

I've posted a demonstration of how to do this in the Macro Library category:

Thanx Peter,

That’s sheer sorcery and exactly what I was hoping to find :+1: