The script is doing everything i want to but it is not picking the first/oldest file from the folder P:\Gensrvnt\workdir\CUSTDCHECK\
echo on
cd..
cd workdir\CUSTDCHECK
IF NOT EXIST P:\Gensrvnt\workdir\CUSTDCHECK\o_100_00000000* GOTO end
REM GET CURRENT TIME(MINUTES only!!)
set mm=%time:~3,-6%
REM get date time of files in folder &REM GET FILE TIME( IN MINUTES!!)
for %%a in (*.*) do set FileDate=%%~ta
set ff=%filedate:~14% There will be multiple filedata listed but I only want to assign the ff variable to the oldest file time
REM Calculate the difference between minutes of current time minus minutes of the file
set /a cc= %mm%-%ff%
REM if difference is more than 10 then we have an error.
if /i %cc% GTR 10 (echo Error) ELSE echo no error
:end
echo this is the end my friend!
need to only select the time of the oldest file
Moderator: DosItHelp
Re: need to only select the time of the oldest file
to grab the oldest "print" the youngest first:
Code: Select all
for /f "delims=" %%a in ('dir /b /o-d /a-d') do SET "filedate=%%~ta"
echo %filedate%