Skip to content

Scripting Retrobatch Pro Using Shell Scripts

The Shell Script node will allow you to call command line (shell script) tools at the start of your workflow (Preflight), at the end (Postflight), or for "Every Image".

It's the "Every Image" option where you can write your own shell scripts to send your images to other tools which can modify the image, or upload it to a server, or perform some other action on it.

The path of the image is given as the last argument.

If you want Retrobatch to read a modified image, print to stdout outputImagePath: <path to script> as part of your script.

If you want Retrobatch to read a modified image via stdout, your script can print imageData: and then the binary contents of your image (see the second example below for a demonstration).

Here's an example using sips to rotate an image:

#!/bin/bash

# The last argument given to a script is the last known path of the image Retrobatch is passing to it.

imagePath="${@: -1}"

fileName=`basename "$imagePath"`

/usr/bin/sips --rotate 45 "$imagePath" --out "/tmp/$fileName"

# Tell Retrobatch where to read our modified image from.
echo "outputImagePath: /tmp/$fileName"

You can also send the image back to Retrobatch using stdin. Here's a convoluted example which replaces every image with a screen capture

#!/bin/bash

screencapture /tmp/foo.png

echo "imageData:"

cat /tmp/foo.png

Common Problems

If you script isn't running, you need to make sure you've set the permissions to "executable". To do this using the Terminal app, you can type the command chmod 755 <path to script>.