Solved

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

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl - Mawk 2 96
Union rows in array that have common elements (Part 2) 4 75
combine multiple lines 2 60
Able to retrieve only 1 row through email amongst multiple rows 3 36
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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.…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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