This simple post-process .bat file illustrates what you've observed:
@echo off echo %* >> \\Mac\Home\Desktop\post.log
When I exported 181 files, LR invoked the .bat file 6 times, with the number of file arguments varying from 5 to 32.
In LR 5 and earlier, an export of many pics would process the pics 1 at a time. But in LR 6, export was parallelized to take advantage of multiple processors (cores). LR divides the selected photos into batches, with a different thread working on each batch. When a batch is finished, LR invokes the post-processing action on that batch. In general, this is a good thing, since exports go significantly faster in LR 6 than previous versions.
Thanks johnrellis. Your explanation makes a lot of sense as to the cause. But, if I select "Show in Explorer", it only opens one window. So, somehow there's a way to have just one thing happen after the entire export job completes. Do you know of any way to trigger this? Or better yet, any way to get around this new parallelism behavior with custom actions happening multiple times? I find it hard to believe that this was a design feature.
I did some further investigation. It turns out that LR limits the command line length to around 1,400 characters. So, depending on the number of photos being exported, plus the path and file name for each photo, one or more command windows will be started. This seems like a new behavior for LR.
To test this, I exported 37 photos. The first complete file name is E:\Users\Scott\Desktop\Test\Test-1.jpg. With this naming sequence, the first command window processed 35 photos and the second window processed two photos. I then added one character on to the file name (E:\Users\Scott\Desktop\Test\TestA-1.jpg). In this test, the first window processed 34 photos and the second window three photos. Both times the line length was just shy of 1,400 characters.
I hope someone knows how to get around this limit.
I don't know how to work around the issue, unfortunately.
It can be useful to have the post-process actions for the batches run in parallel when the actions themselves consume a lot of CPU.