Getting file creation dates...

E

Ed Landau

Can someone tell me how to get all the file names and their creation dates
from a directory?
I have the following which only gives me file names:


opendir(DIR, ".") or die "Cannot open current directory\n";
my @files = readdir DIR;
closedir DIR;


Thanks
-Ed
 
T

Tintin

Ed Landau said:
Can someone tell me how to get all the file names and their creation dates
from a directory?
I have the following which only gives me file names:


opendir(DIR, ".") or die "Cannot open current directory\n";
my @files = readdir DIR;
closedir DIR;

Depends which OS you are running on.

If it's a Unix system, you can not get the creation date of a file unless
you have stored the information elsewhere.
 
W

Walter Roberson

::> Can someone tell me how to get all the file names and their creation dates
:> from a directory?

:Depends which OS you are running on.

:If it's a Unix system, you can not get the creation date of a file unless
:you have stored the information elsewhere.

Quite true, at least in traditional unix filesystems. The field
that many people think of as "creation time" is really the time
of the last status change:

st_mtim Time when data was last modified. Changed by the following
system calls: creat, mknod, pipe, utime, and write. The
seconds portion of st_mtim is available as st_mtime.

st_ctim Time when file status was last changed. Changed by the
following system calls: chmod, chown, creat, link, mknod,
pipe, unlink, utime, and write. The seconds portion of st_ctim
is available as st_ctime.


It looks to me, though, that the original poster could use a nudge
towards the perl 'stat' function.
 
E

Ed Landau

I'm actually running WindowsXP (Active Perl).
I've found the following:

my $FileModifyDate= (stat($fileName))[9];

But what I'm really interested in is the following:

Some directories have files which are JPGs downloaded from my digital
camera. Windows has information called: "Date picture was taken". I don't
know if this is just the creation date renamed or what... but I'd love to
get a hold of it.

-Ed
 
W

Walter Roberson

:Some directories have files which are JPGs downloaded from my digital
:camera. Windows has information called: "Date picture was taken". I don't
:know if this is just the creation date renamed or what... but I'd love to
:get a hold of it.

Ah, that's completely different. There is a standard for embedding
creation information in picture files, calle Exif .
Looks like you should be able to use the Image::EXIF module to
get at it.
 
A

Ala Qumsieh

Ed said:
Some directories have files which are JPGs downloaded from my digital
camera. Windows has information called: "Date picture was taken". I don't
know if this is just the creation date renamed or what... but I'd love to
get a hold of it.

It's encoded in the header of the jpeg file itself. Fortunately, there
are modules to help you extract it. Check out JPEG::JFIF on CPAN.

--Ala
 
E

Ed Landau

Any clue where to get this? Sourceforge doesn't and ActiveState.com doesn't
mention it either. Google didn't do much better....

-Ed
 
J

Juha Laiho

Any clue where to get this? Sourceforge doesn't and ActiveState.com
doesn't mention it either. Google didn't do much better....

Seems to be available on CPAN.
 
M

Martin Herrmann

:Some directories have files which are JPGs downloaded from my digital
:camera. Windows has information called: "Date picture was taken". I don't
:know if this is just the creation date renamed or what... but I'd love to
:get a hold of it.

Ah, that's completely different. There is a standard for embedding
creation information in picture files, calle Exif .
Looks like you should be able to use the Image::EXIF module to
get at it.

I recommend Image::Info to get the EXIF info, because it needs no external libs etc.

Regards
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top