Run Workflows in Background (headless)

Hi there,

is it possible to run a workflow from within an AppleScript completly in background without opening the Dock icon or at least without a temporary document window?

I know about the Droplets, but it seems I can’t run them from AppleScript so that my script can wait until the processing is finished. Launching the Droplet also seems way slower than executing workflow files within the already opened Retrobatch.app.

Cheers, Tekl

1 Like

Basically, no. The app needs to be launched and running to run it’s AppleScript commands.

Is there an alternative way to run workflows maybe from shell?

It would be okay if Retrobatch needs to be open for AppleScript, but how to avoid the workflow document from appearing and disappearing in background?

1 Like

I’ve a simple solution to avoid document opening. I run the droplet using the shell command open with the wait parameter:

do shell script "open -W -a '/Path/to/Droplet.app' " & quoted form of InputFilePath

There’s no way to avoid the document opening and closing, it just needs to happen for Retrobatch to run the workflows.

You can however use Retrobatch from a shell like so:

Retrobatch.app/Contents/MacOS/Retrobatch --workflow path/to/workflow.retrobatch --output ~/Desktop/foo/ /path/to/files.jpeg /or/folders/

2 Likes

Uh, thanks. That’s great. I haven’t found that information in the docs.

It’s in the release notes, and hasn’t quite made it’s way over to the docs yet.

1 Like

Thanks for this shell tip, Gus!

I just tweaked my “3D car to 2D sprite” rendering workflow to run from the shell, and will now do the same with the RetroBatch post-processing aspect of it.

Cheers!

@ccgus do I need to set up my workflow to cope with the fact it’s being called from the command line? Do I need a Read and/or Write nodes?

I ask because… I can’t get it to work.

edit: path to files/folder needs to be absolute, a ~/relative path will not work. no read node required.

So I now have it working but I need some way of specifying order because I’m not sure what order this is exactly? It’s not alphabetical.

should be more like:

What is the exact command you are giving RB from the shell?

/Applications/Retrobatch.app/Contents/MacOS/Retrobatch --workflow ~/Projects/Playdate/dailydriver/Source/Vehicles/Headless.retrobatch --output ~/Downloads/2020-10-12/out /Volumes/External/Users/matt/Projects/Playdate/dailydriver/Models/new-bubble

the file that ends up in the out folder has a name defined by the write node.

i usually define read order in a “read folder” node.

I checked filesystem order and it’s not that other as far as I can tell.

OK, what RB is doing is just asking the file system to return the values in folders, and no sorting is being done after that. (APFs doesn’t have a sorting order when just saying “hey, what are the files in the dir”).

I’ll have to come up with a default I suppose, which should probably be case insensitive alphabetical.

Try the latest build and let me know if it works better for you. If not, can you supply me with the input images you’re using?

http://flyingmeat.com/download/latest/#retrobatch

1 Like

Much better!

Though now, of course, I realise that I am using reverse ordering. :man_facepalming:

So it would be cool if I could pass a list of files somehow? So I can control the ordering on the command-line and pipe it to RB? Or some other solution.

my workaround: generate/write my files out in reverse order :upside_down_face:

Prior to the update I just made, you could pass files individually and it’d go in the order you gave. But when it loaded up folders, those wouldn’t have any seemingly order to them. Maybe I should only do the sorting for folders?

Alright, a reply to myself. I’ve changed it so that only items loaded from a folder are sorted. Otherwise, everything should be processed in the order they are given to the shell command. Grab the latest build here: http://flyingmeat.com/download/latest/#retrobatch

1 Like

I’ll try to today, thanks, because I got stuck in a real mess half way through reversing my writing order.

I did end up reversing the order of my file generation, as /folder/*.PNG and /folder/ had the same result for me. Maybe there’s another way but it didn’t occur to me so that was that - it’s working for me and I’m happy. Cheers