user2593173
user2593173

Reputation: 327

Compare the file timestamp with current time in .bat file

I have a windows script for reading file that is put by an application within a time limit. The script times out in 1 min. If the application was late in putting the file then there will be an old file lying in the folder. Next time the script is executed it will read the old file instead of the new one.

I want to compare the timestamp of the file with the timestamp the script was executed. How can I get the timestamp when the file was placed on the folder in .bat file?

Thanks

Upvotes: 0

Views: 3046

Answers (1)

Endoro
Endoro

Reputation: 37569

try this, it is for the default European time format:

for %%a in (file) do set "filestamp=%%~ta"
set "datestamp=%date%  %time:~0,5%"
if "%datestamp%"=="%filestamp%" (
    rem read this
) else (
    rem read this NOT
)

Upvotes: 3

Related Questions