Write a batch file for selective copy.

I hope you are in the right part of the forum.
I have no real experience writing batch files, so please be kind.

It’s really a query about selecting files to copy, from one download folder, to another folder; are photos that have been created on a camera while “Focus Stacking”

Essentially, on some Olympus cameras, and perhaps others, there is a feature where one can take multiple images, each at a slightly different point of focus, to give greater depth of field.
These can be stacked in external software, say 100 images, and the resulting photo will have a much greater depth of field.
This is pretty simple and you just select the 100 images you need and stack them in “Helicon Focus” or a similar package.

On Olympus, there is also the possibility to do this in the camera, which is where my query begins.
With one press of the shutter, the camera takes 15 images, writes them to the card, as *.jpg and a matching *.orf
The .orf is the Olympus proprietary raw file.
The camera then processes all 15 image pairs and creates a single .jpg, no associated .orf, so for one shutter press, there are 31 files in total; 15 pairs + a stacked jpg.

I would like to write a batch file, to copy all these orphan stacked .jpg files to another folder, like success stacks.
The problem is that if one moves the camera, or let’s say the bug moves, the stacking attempt fails; the camera tells you this, it still writes 15x * .jpg + 15x * .orf, but there is no additional stacked orphan jpg.

For this reason, I can’t just copy every 16 *.jpg, as it will be out of sequence after a failed “in-camera” stack.

The camera generates file numbers that increment +1 for each exposure, for example (P8280101.jpg + P8280101.orf) up to +15 (P8280116.jpg + P8280116.orf) and I want to copy the next successful stacked file P8280117.jpg but only if it has worked correctly, and therefore there is no P8280117.orf; otherwise, P8280117.* simply becomes the start of the next pair of 15 matching shots.

I found a batch file to copy each Nth jpg, which I have modified, and it works fine, but only works if there are no rendering errors, as it lags afterwards.

@echo off

set counter = 0

for %%f in (*.jpg) call :P “%%F”

go to: eof


set /a Counter+=1

set /a X=Counter %% 16

if %X%==0 copy %1 “F:\stacks\stacked”

go to: eof

Sorry I can’t get rid of the emotes above, so for each :P please read: p but without the space between the colon and the p.

I really need some kind of line that states “IF” there is no *.orf to match a given *.jpg, then copy “it”.jpg to a different folder and then move on to the next; unfortunately, I have no idea how to achieve this, and my last programming experience in Basic was over 40 years ago.

Any kind soul with any helpful ideas please?
Thank you very much

Edited by peak4, Today, 03:09 PM.

Leave a Comment