Solved How to Search for files, compare date created, apply action

October 7, 2020 at 09:24:46
Specs: Windows 10

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.


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)

@echo off


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!







I would appreciate any advise. I have been searching for a few days on a solution but I can't get anything to work as my understanding is very limited.

Thank you kind sirs!

See More: How to Search for files, compare date created, apply action

October 7, 2020 at 20:41:03
✔ Best Answer
@echo off & setlocal
:: assuming type is .jpg. Could be anything
for /f "tokens=*" %%a in ('dir /b A_LDB\*.jpg /o-d') do (
set k=%%a
call :kopy %%a
echo done.
goto :eof

echo incoming %1 %~t1

Reply ↓  Report •
Related Solutions

Ask Question