On Aug 19, 2013, at 7:27 PM, beginners-digest-h...@perl.org wrote:

> 
> beginners Digest 20 Aug 2013 00:27:53 -0000 Issue 4569
> 
> Topics (messages 123372 through 123374):
> 
> Re: Fetching File Creation Date
>       123372 by: John Aten
>       123373 by: Shawn H Corey
>       123374 by: Jim Gibson
> 
> Administrivia:
> 
> To subscribe to the digest, e-mail:
>       <beginners-digest-subscr...@perl.org>
> 
> To unsubscribe from the digest, e-mail:
>       <beginners-digest-unsubscr...@perl.org>
> 
> To post to the list, e-mail:
>       <beginners@perl.org>
> 
> 
> ----------------------------------------------------------------------
> 
> From: John Aten <welcome.to.eye.o.r...@gmail.com>
> Date: August 17, 2013 8:57:14 AM CDT
> To: beginners@perl.org
> Subject: Re: Fetching File Creation Date
> 
> 
> From: Lawrence Statton <lawre...@cluon.com>
> Date: August 16, 2013 6:09:15 PM CDT
> To: beginners@perl.org
> Subject: Re: Fetching File Creation Date
> 
> On 08/16/2013 04:25 PM, John Aten wrote:
> > Does anyone know if this is possible? Or should I just accept the
> > fact that all dates before 8/2013 are suspect?
> 
> >> There is no datum that is closely correlated to the "file creation" time.
> 
> Thanks for the reply. I was taking 'creation time' as the time of the first 
> save. Does that matter?
> 
> 
> 
> From: Shawn H Corey <shawnhco...@gmail.com>
> Date: August 17, 2013 9:50:48 AM CDT
> To: beginners@perl.org
> Subject: Re: Fetching File Creation Date
> 
> 
> On Sat, 17 Aug 2013 08:57:14 -0500
> John Aten <welcome.to.eye.o.r...@gmail.com> wrote:
> 
>> Thanks for the reply. I was taking 'creation time' as the time of the
>> first save. Does that matter?
> 
> In UNIX et al., there is no such thing. There are 3 times stored in
> most file systems (FS) under UNIX.
> 
> atime -- access time, the time of the last access
> 
> mtime -- modification time, the time when the data of the file was last
> modified.
> 
> ctime -- change time, the time the i-node information was last changed.
> 
> Some FS don't always update the access time.
> 
> 
> -- 
> Don't stop where the ink does.
>       Shawn
> 
> 
> 
> From: Jim Gibson <jimsgib...@gmail.com>
> Date: August 17, 2013 12:03:50 PM CDT
> To: "begin >> Perl Beginners" <beginners@perl.org>
> Subject: Re: Fetching File Creation Date
> 
> 
> 
> On Aug 16, 2013, at 2:25 PM, John Aten wrote:
> 
>> Hi all,
>> 
>> I am working on a script to rename files after a formula (discussed here: 
>> http://www.drbunsen.org/naming-and-searching-files-part-1/ ) . The formula 
>> calls for an ID string that is constructed from the date and time the file 
>> is created, of the format YYYMMDD_HHMMSS. The closest approximation of the 
>> file creation date that I can find thus far is the inode change time 
>> returned by the stat() function. I was under the impression that this would 
>> not be too far off from the first save date, but from what I later read and 
>> my experimentation, it seems VERY far off the vast majority of the time. The 
>> inode change time is more often than not exactly the same as the last 
>> modification time, and even when it's not it's nowhere close to the actual 
>> date/time of the first time the file was saved.
>> 
>> The ID string here serves two purposes: to make a unique identifier, and to 
>> put the files in order by creation date and time. At the very least I figure 
>> using the inode change time should produce unique identifiers, but I would 
>> like to have chronological order if possible. Unfortunately, I am starting 
>> to believe that this is not possible. I have files going back to the mid 
>> 1990's, coming from various versions of Windows, as well as files produced 
>> over the last few years natively on the Mac. Even the creation dates/times 
>> of the native Mac files, as listed in the finder, seem radically incorrect. 
>> 
>> Does anyone know if this is possible? Or should I just accept the fact that 
>> all dates before 8/2013 are suspect?
> 
> I would recommend the file modification time as your best bet. 
> 
> The times stored for each file are dependent upon the operating system and 
> file system in use. Not all OS/FS systems are the same. Unix doesn't save the 
> "creation time", when the file was originally created. However, Mac OS X and 
> HFS+ do, and the creation times are maintained through moving and copying 
> operations. I have files on my Mac that date back to 1984, which was several 
> computers ago. I don't know about Windows.
> 
> Unix saves the access time, file modification time, and inode change time. 
> The inode change time is updated frequently, whenever the files metadata or 
> content changes, Perl's stat() function returns these three, as do the -M, 
> -A, and -C file tests.
> 
> The problem on the Mac is getting at the creation time. You could try the 
> MacOSX::File::Info module, which claims to do it, but that module hasn't been 
> updated recently and it will not build on my 10.7.5 system.
> 
> If you have Developer tools installed, then you can use the 
> /Developer/Tools/GetFileInfo utility to print out the file creation time. You 
> can call that from your Perl script with backquotes and capture the output:
> 
>  my @data = `/Developer/Tools/GetFileInfo $fullpath`;
> 
> Then parse data for the 'created:' line.
> 
> See this link for more information about file times in the various operating 
> systems:
> 
> <http://thomas.kiehnefamily.us/whats_in_a_creation_date>
> 
> Good luck.
> 

Thanks to everyone for the replies, and especially to Mr. Gibson for the tip 
about GetFileInfo.

I looked at the MacOSX::File::Info module, but I am guessing that even if I 
could get it installed it would likely return the same info as the GetFileInfo 
utility.

I've played around with comparing the dates returned by GetFileInfo and the 
inode change time returned by perl's stat() function. It appears that the field 
that GetFileInfo reports as file creation time is highly suspect as well; on 
many files the 'creation date' is after the inode change date! I've seen this a 
significant portion of the time even on files that were created and have lived 
their whole life on the mac. I think I'm putting more effort in here than the 
matter is ultimately worth, but I think I have found a solution that gets rid 
of the problem and allows me to be obsessive: a subroutine that looks at all 
the possible dates and times and selects the earliest. 

Thanks again for the help!

Reply via email to