Queues for custom commands

The built-in copy command has a functionality that allows to queue up operations. This functionality would also be useful to custom commands (e.g. when running batch jobs like video converters on selections). Is there some scripting API that allows to use the built-in queue functionality for custom commands?

You can run multiple commands against a selection, one after another, very easily.

Is that all you need? Or do you need the full queuing functionality, where you can select some files, start something going, then select some other files and queue the actions for the second selection so they only start once the actions for the first selection complete?

I would need the latter. The reasoning is basically the same as for the copy queues - it doesn't make sense to run video conversion commands in parallel as they would fight for computing resources just like multiple copy commands would fight for IO.

You could do it using scripting, but you'd need to roll your own way for the two (or more) instance of the script to synchronize with each other.

One way would be to have each script check if any of the video conversion processes were running and wait if they are. That might mean that two waiting scripts start things at the same time, however.

Another simple way would be for the scripts to create a temp file with a name/path that is unique to the scripts, and leave it locked in write mode. If the file cannot be opened/created for writing then they know another instance of the script already has it open and can wait and try again until they get the file, then close the file just before they finish.

Opus also provides variables which scripts can share between themselves, which could be used to add things to a work queue. But you'd need to be careful to synchronize access to those variables to avoid losing items, and I think something like the temp-file idea would be a lot easier.

I see, I just wanted to check if there was maybe a way to ride on existing queueing functionality that is used by the built-in copy operations before re-inventing the wheel, but since there isn't I'll try to roll my own. Thanks for the super-quick reply!

1 Like