How can you compare file dates?

View: New views
3 Messages — Rating Filter:   Alert me  

How can you compare file dates?

by asdf_phyman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm running XP and I'd like to know if someone knows how to compare two
different files' dates.

Here's what I'd like to do:

if filedateX is older than filedateY(

     rem do something
)

But I can't seem to find a way to do this. Is there any way to get a
files time/date stamp so that it can be placed in a variable for
comparison?

FC doesn't seem to work as it seems to do everything else except provide
a time/date stamp. I've read that Forfiles can do something like this
but my system nor will the target systems doesn't have this option.

Any help would be appreciated.

Paul




Re: How can you compare file dates?

by foxidrive-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 05 Mar 2008 16:24:35 -0000, "asdf_phyman" <phyman@...>
wrote:

>I'm running XP and I'd like to know if someone knows how to compare two
>different files' dates.
>
>Here's what I'd like to do:
>
>if filedateX is older than filedateY(
>
>     rem do something
>)
>
>But I can't seem to find a way to do this. Is there any way to get a
>files time/date stamp so that it can be placed in a variable for
>comparison?
>
>FC doesn't seem to work as it seems to do everything else except provide
>a time/date stamp. I've read that Forfiles can do something like this
>but my system nor will the target systems doesn't have this option.

Will the two file be in the same folder?

Re: How can you compare file dates?

by Eduardo Joaquim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello my friend,

follow one solution for your problem. Compare file Dates...
I'had tested on my computer. Important understand to proper run
this program, you need to set the format date to MM/DD/YYYY.

You should change this program as necessary... but, please, publish
my e-mail and Name as follow.


rem start--------------------

@echo off
set fileX="%~1"
set fileY="%~2"

for /f %%A in ('dir /b %fileX%') do set dateTimeX=%%~tA
for /f %%A in ('dir /b %fileY%') do set dateTimeY=%%~tA

rem FORMAT DATE TIME mm/dd/yyyy hh:mm:ss
rem Capture partial date from dateTime
set mX=%dateTimeX:~0,2%
set dX=%dateTimeX:~3,2%
set yX=%dateTimeX:~6,4%

set mY=%dateTimeY:~0,2%
set dY=%dateTimeY:~3,2%
set yY=%dateTimeY:~6,4%

if /I %yX% GEQ %yY% (
  echo year X^(%yX%^) ^>= year Y^(%yY%^)
  if /I %mX% GEQ %mY% (
    echo month X^(%mX%^) ^>= month Y^(%mY%^)
    if %dX% GTR %dY% (
      echo day X^(%dX%^) ^> day Y^(%dY%^)
    ) else (
      if %dX% EQU %dY% (
        echo day X^(%dX%^) = day Y^(%dY%^)
      ) else (
        echo day X^(%dX%^) ^< day Y^(%dY%^)
      )
    )
  )
)

rem -----------------------------------------------
rem Wrote by Eduardo Joaquim da Silva
rem From Brazil
rem e-mail: ejsbr@...
rem end--------------------------------------------








--- In batchworld@..., foxidrive <foxidrive@...> wrote:
>
> On Wed, 05 Mar 2008 16:24:35 -0000, "asdf_phyman" <phyman@...>
> wrote:
>
> >I'm running XP and I'd like to know if someone knows how to
compare two

> >different files' dates.
> >
> >Here's what I'd like to do:
> >
> >if filedateX is older than filedateY(
> >
> >     rem do something
> >)
> >
> >But I can't seem to find a way to do this. Is there any way to get
a
> >files time/date stamp so that it can be placed in a variable for
> >comparison?
> >
> >FC doesn't seem to work as it seems to do everything else except
provide
> >a time/date stamp. I've read that Forfiles can do something like
this
> >but my system nor will the target systems doesn't have this option.
>
> Will the two file be in the same folder?
>


LightInTheBox - Buy quality products at wholesale price