for /D %%A in (*) do call :doCopy "%%A"
That presumably passes the path of all folders and subfolders to the subroutine ?
It passes the names of the subfolders, such as "3350", "3351", ... in your case.
We need to ignore if that subfolder does not exist at that level.
I tried the following but it does not work :-
do IF EXIST "%%A\LEFT" call :doCopy "%%A"
Try IF EXIST in the subroutine, not in the main loop. Or rather IF NOT EXIST ... GOTO :LABEL
IF EXIST body may contain several commands, which you enclose in (...), such as
if not exist "%~dp1*.raw" (
echo No RAW files, exiting...
goto :pause
)
Remember, LEFT and RIGHT only occur at the lowest level, not in all subfolders.
I assumed your directory structure was this:
Consider the following directory structure :-
DCIM/
3350/LEFT/
/RIGHT/
3353/LEFT/
/RIGHT/
3356/LEFT/
/RIGHT/
The LEFT and RIGHT folders contain images (3350_001.RAW, 3350_002.RAW and 3350_003.RAW, for example).
Each folder also contains file STRIPS.HDR.