Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

809 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