We use this script to help us pull images out of folders in a directory from 1 camera, copy it to the parent folder and rename it to that of the folder name from which it came.
This is necessary as we have 170 different cameras taking multiple pictures, we manually place them into folders with a chosen name and do this up to 100 times in a day. Its for 3D scanning for vfx. At the end of the day, we run the script to get the main front image of what we scanned from each folder so we can see what we've done.
problem
Currently, it does its job but it needs improving. The camera (A_LDB) we want the image from outputs 3 images into the folder so the script therefore outputs all 3 images from the folders. We then go and delete 2 of the 3 images and keep the 1 we want. The 1 we want is the first of the 3 (ie. oldest file)
What code can I add to this script so that it finds the oldest images and only copies that one OR How do you have it delete the 2nd and 3rd image automatically after copying them (less efficient but acceptable)
Code: Select all
@echo off
SETLOCAL enableextensions ENABLEDELAYEDEXPANSION
set counter=0
for /r %%a in (".\*") do for %%b in ("%%~dpa\.") do (
set filename=%%~na
echo.!filename! | findstr /C:"A_LDB" 1>nul
if errorlevel 1 (
rem DO NOTHING
) ELSE (
set /a counter=counter+1
set parent=%%~nxb
set type=%%~xa
copy "%%a" !cd!\!parent!"_cs"!counter!!type!
)
)
popd
echo !counter! FILES HAVE BEEN COPIED
pause
Thank you kind sirs!