Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch to look at file creation date  (Read 2802 times)

0 Members and 1 Guest are viewing this topic.

andybeanland

  • Guest
Batch to look at file creation date
« on: July 01, 2005, 02:12:11 AM »
Hello,

I'm trying to write a batch file (an additional to the users logon script) to find the modified date of a file, then find the difference between todays date and if the difference is greater than 100 days run a certain piece of software.

I'm sure this is fairly easy, but I'm pretty new to batch files. All I've managed to do so far is to output todays date to a text file. I think you can get the creation date using the "DIR filename", but this will need to be trimmed and I'm not sure how to do that in batch files.

Any help would be much appreciated

Thanks for your help

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch to look at file creation date
« Reply #1 on: July 01, 2005, 05:21:11 AM »
There are three dir switches available for dates:

/ta - date accessed
/tc - date created
/tw- date written

Calculations in batch files can be done with the set /a statement. That  said, date calculations are cumbersome and usually involve a long series of hardcoded IF statements.

A better tool would be Windows Scripting (free and installed on Windows machines since Win95C) which has built in date functions for just the purpose you need.

http://www.microsoft.com/technet/scriptcenter/default.mspx

Good luck. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein