Solved

How can I get a timestamp of a file in  Windows32 system?

Posted on 2001-09-04
5
130 Views
Last Modified: 2012-08-13
I'm reading Windows directry & try to get the timestamps for a file (Last Modified, Last Accessed, File Created). I know there is a function 'stat' or 'lstat' for Unix based perl, but these are not supported in Windows env... Please help me.
0
Comment
Question by:koko973
  • 4
5 Comments
 
LVL 8

Expert Comment

by:bebonham
ID: 6454882
use dir


 /T          Controls which time field displayed or used for sorting
 timefield   C  Creation
             A  Last Access
             W  Last Written


I will see if I can come up with a sub for you.
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6454899
short and sloppy...

but it'll get you by.


ts("A");

sub ts
{
$v=shift;
$ret=`dir /T$v`;
@arr=split("\n",$ret);


foreach(@arr)
{
$_=/([^ap]+)(.)/;
push(@arr2,$1 . $2);
}
print join("\n",@arr2);
print "done";
}

0
 
LVL 8

Accepted Solution

by:
bebonham earned 50 total points
ID: 6455182
ts("A", 'autoexec.*');  #date type, filename

sub ts
{
($v,$file)=@_;
$ret=`dir /T$v $file`;
@arr=split("\n",$ret);


foreach(@arr)
{
$_=/([^ap]+)(.)/;
push(@arr2,$1 . $2);
}
print join("\n",@arr2);
print "done";
}

0
 

Author Comment

by:koko973
ID: 6457391
You are good!!!
Thanks a lot :-) Much appreciated.

0
 
LVL 8

Expert Comment

by:bebonham
ID: 6457763
anytime!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now