Solved

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

Posted on 2001-09-04
5
134 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl program to obtain a machine's memory usage 6 26
Perl script to parse log and delete the file 17 179
delete query using perl dbi 3 115
Perl Snippet to Parse String 1 39
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…

733 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