Automator: get x number of files (1000s), run workflow in chunks/batches of y (~50) files at a time?

I'm converting a large number of audio files and using the workflow described here to apply the original files' date created to the newly converted files -- Can Automator convert an image AND keep t… - Apple Community


The workflow doesn't work with more than maybe 50 files at a time. But I don't want to have to keep dragging in 50 at a time and pressing run.


Is there a way to drag all 10,000 files I have in, and have a step in the workflow to select just the first 50, run the rest of the workflow, then loop back, select the next 50, run the workflow, etc..?


Thanks!


Parallels, macOS 10.14

Posted on Oct 19, 2022 1:04 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 20, 2022 10:05 AM

I think Automator itself has your answer.


You need to break this into a two-step process.


First, you save the existing workflow as-is.


Then you create a second workflow. This workflow accepts files, and you add the Run Workflow action.


This action has the ability to invoke another workflow (i.e. your existing workflow), in a loop, passing in batches of the current input.


You can indicate the size of the batches (e.g. 50 files at a time), and how many to run concurrently (I suggest 1, but you may live life more dangerously). This workflow does the heavy-lifting of breaking your input into manageable chunks for the existing workflow to manage.

6 replies
Question marked as Top-ranking reply

Oct 20, 2022 10:05 AM in response to markwd21

I think Automator itself has your answer.


You need to break this into a two-step process.


First, you save the existing workflow as-is.


Then you create a second workflow. This workflow accepts files, and you add the Run Workflow action.


This action has the ability to invoke another workflow (i.e. your existing workflow), in a loop, passing in batches of the current input.


You can indicate the size of the batches (e.g. 50 files at a time), and how many to run concurrently (I suggest 1, but you may live life more dangerously). This workflow does the heavy-lifting of breaking your input into manageable chunks for the existing workflow to manage.

Oct 19, 2022 8:20 PM in response to VikingOSX

Thanks for the reply! That solution you wrote before has gotten me way farther than I would've otherwise.


In writing out my followup question just now I actually figured out how to better word a google search for what I need and found a solution!


For anyone dealing with this issue in the future...


This article describes the problem of passing too many files through at once for various Automator workflows/apps. And on page 2 offers an add-on Automator action for incrementally sending through one file at a time --

https://www.peachpit.com/articles/article.aspx?p=1327771


The download link doesn't work anymore but I found it on wayback machine --

http://web.archive.org/web/20210613145310/http://automator.us/leopard/downloads/index.html


Oct 19, 2022 1:49 PM in response to markwd21

It's been three years and I didn't remember writing that linked solution. Re-read my last entry there about the maximum number of filename bytes in arguments that are allowed in a UNIX command line such as Terminal, or an Automator Run Shell script. In Mojave, it is a restricted 262,144 bytes and that is why you cannot drag and drop 10,000 filenames on an Automator application, or select that many in the Finder (if you could) for a Quick Action.

Oct 20, 2022 9:54 AM in response to VikingOSX

Hmm yeah you are wise. I did test it before posting (I'm on Big Sur) but when I got to higher numbers I started having an issue.

The action “Dispense Items Incrementally” encountered an error: “Can’t get |temporary items path| of {action:item id 1, ignoresInput:false}.”


I've noticed I get that error immediately if I go click on just about anything in Finder while it's running. If I do nothing, it runs through 10-15 files before getting the error.


Any suggestions greatly appreciated!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator: get x number of files (1000s), run workflow in chunks/batches of y (~50) files at a time?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.