# A file's creation date

**URL:** <https://rubytalk.org/t/a-files-creation-date/43531>\
**Category:** ruby-talk\
**Created:** [5 January 2008 11:27 UTC](https://rubytalk.org/t/a-files-creation-date/43531 "2008-01-05T11:27:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_L\_Versteegen](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@Peter\_L\_Versteegen](https://rubytalk.org/u/Peter_L_Versteegen)\
**Post date:** [5 January 2008 11:27 UTC](https://rubytalk.org/t/a-files-creation-date/43531/1 "2008-01-05T11:27:24Z")

</div>

Hello anyone,

I have written a script that organizes my ten thousand+ photos into a year/month file structure using 'exifr' while eliminating duplicates. Unfortunately some of the dates in the 'EXIF' block are bad or non existing. In the latter case, the file's creation date is the closest I can come to as a date to use for the photograph, and even that is sometimes flawed. However, I cannot find a method for retrieving the creation date of a file. The file class has 'atime', last access time, and 'ctime', lst changed time. I have googled and googled but can't find a way. Can anyone help?

Thanks ahead of time.

Pete  
[pversteegen@gcnetmail.net](mailto:pversteegen@gcnetmail.net)

---

<div class="post-metadata">

**Author:** ![Pascal\_Bourguignon](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@Pascal\_Bourguignon](https://rubytalk.org/u/Pascal_Bourguignon)\
**Post date:** [5 January 2008 12:19 UTC](https://rubytalk.org/t/a-files-creation-date/43531/2 "2008-01-05T12:19:57Z")

</div>

Peter L Versteegen \<pversteegen@gcnetmail.net\> writes:

> [Note: parts of this message were removed to make it a legal post.]
> 
> Hello anyone,
> 
> I have written a script that organizes my ten thousand+ photos into a  
> year/month file structure using 'exifr' while eliminating duplicates.  
> Unfortunately some of the dates in the 'EXIF' block are bad or non  
> existing. In the latter case, the file's creation date is the closest  
> I can come to as a date to use for the photograph, and even that is  
> sometimes flawed. However, I cannot find a method for retrieving the  
> creation date of a file. The file class has 'atime', last access  
> time, and 'ctime', lst changed time. I have googled and googled but  
> can't find a way. Can anyone help?
> 
> Thanks ahead of time.

Think ahead of time. I mean, if you want to keep the creation time,  
you have to think of it when you create the file, because the unix  
systems won't do that for you.

For example, just before downloading your pictures, you could create a  
directory named with the time stamp:

d=pictures-$(date +%Y%m%d) ; mkdir $d ; cd $d ; fetch-pictures-from-camera

you can also use:  
d=pictures-$(date +%Y%m%dT%H%M%S)  
if you do that several times the same day.

There are also programs to edit the EXIF block, perhaps you could use  
one to add the creation data in the files?

> **···**
>
> --  
> \_\_Pascal\_Bourguignon\_\_ \_ Software patents are endangering  
> () ASCII ribbon against html email (o\_ the computer industry all around  
> /\ 1962:DO20I=1.100 //\ the world [http://lpf.ai.mit.edu/](http://lpf.ai.mit.edu/)  
> &nbsp;&nbsp;&nbsp;&nbsp;2001:my($f)=`fortune`; V\_/ [http://petition.eurolinux.org/](http://petition.eurolinux.org/)

---

<div class="post-metadata">

**Author:** ![Peter\_L\_Versteegen](https://avatars.discourse-cdn.com/v4/letter/p/dbc845/32.png) [@Peter\_L\_Versteegen](https://rubytalk.org/u/Peter_L_Versteegen)\
**Post date:** [5 January 2008 13:11 UTC](https://rubytalk.org/t/a-files-creation-date/43531/3 "2008-01-05T13:11:58Z")

</div>

Pascal,

Thanks for your comments. I do download with into a time stamped directory using QPICT. This does a great job.  
I'm more careful now to make sure that my cameras are set to the correct date and time, but this is all about past pictures, and the date and time that you find in Finder's Get Info. I would like to retrieve the date and time that the file was created and eventually insert them in the EXIF field. I have several hundred photos whose EXIF fields are mangled!

Pete

> **···**
>
> On Jan 5, 2008, at 7:19 AM, Pascal Bourguignon wrote:
> 
> > Peter L Versteegen \<pversteegen@gcnetmail.net\> writes:
> > 
> > > [Note: parts of this message were removed to make it a legal post.]
> > > 
> > > Hello anyone,
> > > 
> > > I have written a script that organizes my ten thousand+ photos into a  
> > > year/month file structure using 'exifr' while eliminating duplicates.  
> > > Unfortunately some of the dates in the 'EXIF' block are bad or non  
> > > existing. In the latter case, the file's creation date is the closest  
> > > I can come to as a date to use for the photograph, and even that is  
> > > sometimes flawed. However, I cannot find a method for retrieving the  
> > > creation date of a file. The file class has 'atime', last access  
> > > time, and 'ctime', lst changed time. I have googled and googled but  
> > > can't find a way. Can anyone help?
> > > 
> > > Thanks ahead of time.
> > 
> > Think ahead of time. I mean, if you want to keep the creation time,  
> > you have to think of it when you create the file, because the unix  
> > systems won't do that for you.
> > 
> > For example, just before downloading your pictures, you could create a  
> > directory named with the time stamp:
> > 
> > d=pictures-$(date +%Y%m%d) ; mkdir $d ; cd $d ; fetch-pictures-from-camera
> > 
> > you can also use:  
> > d=pictures-$(date +%Y%m%dT%H%M%S)  
> > if you do that several times the same day.
> > 
> > There are also programs to edit the EXIF block, perhaps you could use  
> > one to add the creation data in the files?
> > 
> > --  
> > \_\_Pascal\_Bourguignon\_\_ \_ Software patents are endangering  
> > () ASCII ribbon against html email (o\_ the computer industry all around  
> > /\ 1962:DO20I=1.100 //\ the world [http://lpf.ai.mit.edu/](http://lpf.ai.mit.edu/)  
> > &nbsp;&nbsp;&nbsp;2001:my($f)=`fortune`; V\_/ [http://petition.eurolinux.org/](http://petition.eurolinux.org/)

---

<div class="post-metadata">

**Author:** ![Pascal\_Bourguignon](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@Pascal\_Bourguignon](https://rubytalk.org/u/Pascal_Bourguignon)\
**Post date:** [5 January 2008 18:10 UTC](https://rubytalk.org/t/a-files-creation-date/43531/4 "2008-01-05T18:10:00Z")

</div>

Peter L Versteegen \<pversteegen@gcnetmail.net\> writes:

> Thanks for your comments. I do download with into a time stamped  
> directory using QPICT. This does a great job.  
> I'm more careful now to make sure that my cameras are set to the  
> correct date and time, but this is all about past pictures, and the  
> date and time that you find in Finder's Get Info. I would like to  
> retrieve the date and time that the file was created and eventually  
> insert them in the EXIF field. I have several hundred photos whose  
> EXIF fields are mangled!

IIRC, on HFS, the creation time is kept. There's a command  
/Developer/Tools/GetFileInfo or something like that that should let  
you get it in the shell, or perhaps from AppleScript, but I don't it.

> **···**
>
> --  
> \_\_Pascal\_Bourguignon\_\_ \_ Software patents are endangering  
> () ASCII ribbon against html email (o\_ the computer industry all around  
> /\ 1962:DO20I=1.100 //\ the world [http://lpf.ai.mit.edu/](http://lpf.ai.mit.edu/)  
> &nbsp;&nbsp;&nbsp;&nbsp;2001:my($f)=`fortune`; V\_/ [http://petition.eurolinux.org/](http://petition.eurolinux.org/)
