Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Set a photo file's creation date to the photo's date System 10.4
A fellow user in another (German) Forum asked for a way to change a photo file's creation date to the date the picture was taken. We also found out that touch also changes Mac OS X's creation date, provided that it's prior to the file's creation date. After a lengthy (German) discussion, I've created an AppleScript (see source links below) that takes care of (I hope) almost all possible cases:
  • If the photo's date is prior to the file's date, a simple touch is done.
  • If the photo's date is prior to today's date, the photo file is copied, so it gets today's date. Then it is touched.
  • Otherwise you have a picture from the future and I'd like to meet you soon ;-) No.. .The script complains and suggests you fix your time settings.
The script is usable in three ways:
  1. Standalone: You will be asked to select the JPEG files that shall be changed.
  2. As a droplet: You may drop JPEGs and folders on it and any JPEG file (recursively) found, will be changed.
  3. As a Folder Action: Like a droplet, but working on all items added to the folder.
The script is in V0.3, and I have had no feedback yet, so I appreciate any feedback. I hope it's useful to some of you. The latest source can be found in this thread on the above-linked forums. The boards are in German, but the AppleScript itself is fairly obvious.

[robg adds: I copied the V0.3 version of the script and added it to our archives, just so there's at least one version always available. But be sure to check the forum link above for newer versions in the future. I have not tested this script.]
    •    
  • Currently 1.86 / 5
  You rated: 3 / 5 (7 votes cast)
 
[39,190 views]  

10.4: Set a photo file's creation date to the photo's date | 12 comments | Create New Account
Click here to return to the '10.4: Set a photo file's creation date to the photo's date' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Set a photo file's creation date to the photo's date
Authored by: littlegreenspud on Jan 05, '07 08:21:16AM
Or use the excellent PhotoToolCM found here:

http://www.pixture.com/software/macosx.php

[ Reply to This | # ]
10.4: Set a photo file's creation date to the photo's date
Authored by: Arlo on Jan 05, '07 08:56:29AM

Second for PhotoCMTools, it's great. I should also point out that this script (and PCT) won't work on RAW files, only JPG. For that, you'd need to use something like A Better Finder Attributes, Aperture or Lightroom.

---
www.automatorworld.com
"Better Living Through Macintosh Scripting"



[ Reply to This | # ]
10.4: Set a photo file's creation date to the photo's date
Authored by: Skeeve on Jan 07, '07 01:00:14PM

I have no RAW files and I don't know whether or no AppleScript can access their EXIF dates if they have one). But if so, it would be more than easy to extend the script, to support other formats too.



[ Reply to This | # ]
10.4: Set a photo file's creation date to the photo's date
Authored by: jdm on Jan 05, '07 09:01:36AM

A nice script that works (in my testing) as advertised.

It would be nice if
a) It gave some feedback when it was successful (e.g. "successfully converted XX dates")
b) It would be nice if you could select a folder from the file open menu. This does seem to work if you compile the script as an application, and drop a folder on the application.



[ Reply to This | # ]
10.4: Set a photo file's creation date to the photo's date
Authored by: Skeeve on Jan 07, '07 01:04:33PM

I'll add feedback.

Selecting a folder seems impossile in AppleScript if you also want to be able to select files. It seems to be either the one or the other. So I decided to stick to file selection when you run the script and use folder and file dropping.

I also wanted to make the script useable as an automator script, but didn't succeed yet.



[ Reply to This | # ]
10.4: Set a photo file's creation date to the photo's date
Authored by: mesa on Jan 05, '07 09:14:34AM
I usually use jhead to access exif data, it has a cli and so isn't everyone's cup of tea.

One point of clarification is that there is no such thing as "creation time", ctime as it is usually called is the time of metadata change. As most files don't have their metadata changed it is often mistaken for creation time.

[ Reply to This | # ]

10.4: Set a photo file's creation date to the photo's date
Authored by: Lankhmart on Jan 05, '07 10:38:17AM

Yes, there really is a creation date for files on HFS+ disks, completely separate from the ctime. None of the unix-based tools on OS X are aware of it, and they all fail to preserve it (using rsync or ditto or tar, for instance), but if you just use Get Info in the Finder you can see it. This is one of the key pieces of Mac-specific metadata that nearly all backup software fails to preserve.



[ Reply to This | # ]
10.4: Set a photo file's creation date to the photo's date
Authored by: merlyn on Jan 05, '07 11:28:42AM
I've been using this Perl script for a long time now:

#!/usr/bin/env perl
use strict;
$|++;

use Image::ExifTool qw(ImageInfo);

use Time::Local;

for my $file (@ARGV) {
  my $ii = ImageInfo($file, qw(DateTimeOriginal DateTime))
    or warn("Skipping $file\n"), next;
  my ($created) =
    grep /\S/, @$ii{qw(DateTimeOriginal DateTime)};
  next unless $created;
  warn "using $created for $file\n";
  if ($created =~ s/([-+ ])(\d\d):(\d\d)$//) {
    my ($sign, $hour, $minute) = ($1, $2, $3);
    # warn "ignoring offset of $sign $hour:$minute\n";
  }
  my @digits = $created =~ /(\d+)/g or next;
  if ($digits[0] < 1900) {
    warn "bad year $digits[0] for $file";
    next;
  }
  $digits[0] -= 1900;
  $digits[1] -= 1;
  my $gmtime = timegm(reverse @digits);
  if ($gmtime > time or $gmtime < time - 86400*90) {
    warn "preposterous gmtime for $file: ", scalar gmtime $gmtime;
    # next;
  }
  utime($gmtime, $gmtime, $file) or warn "Cannot utime on $file: $!";
}
It requires Image::ExifTool installed from the CPAN.

[ Reply to This | # ]
10.4: Set a photo (ANY) file's creation date to the photo's date
Authored by: peterrosen on Mar 21, '08 05:15:10PM

I don't know how it happened, but all of a sudden a bunch of files are now showing modified date of today, rather than the last time they were created or touched. Is there a way to reset the change? I have no idea how these files all either images (png and jpg) and .mov files were changed or what did it? I would sure love a way to be able to see where and when my energy went into the particular image/mov as that's part of how i keep track of my progress and time spent on things. TIA for an APPLESCRIPT ideally, or whatever.

peter



[ Reply to This | # ]
10.4: Set a photo file's creation date to the photo's date
Authored by: barefootguru on Jan 05, '07 11:34:18AM

The ubiquitous GraphicConverter also contains a lot of options for adjusting the file creation/modification date, the EXIF date, etc. (The Date and JPEG pop-up menus in the browser window (despite its nomenclature, the JPEG menu can be used for more than JPEG files))



[ Reply to This | # ]
crazy
Authored by: whitepenguin on Jan 05, '07 06:44:45PM
Seems ridiculous, all of this effort just to coerce OS X into doing what OS 9 did automatically in the Finder... I noticed that GraphicConverter does this conversion too, but in the end, I decided just to use iPhoto, which stamps the correct dates on the files' creation dates as it copies them from your memory card...then I move the resulting files out of the iPhoto library folder to where I want them...

[ Reply to This | # ]
crazy
Authored by: whitepenguin on Jan 17, '07 04:19:36PM
Well I must reply to my own post. I had been using iPhoto 5, which was properly changing the memory card's photo dates to the EXIF date while importing, but I started using iPhoto 6 and lo and behold, that feature is missing!!! What a bummer. Always nice to see apps lose features when they're updated...jeez.

So now I've used the Applescript that the original poster wrote about, but I find that it gives me an error message if I run the script on files copied from a memory stick to the Finder, or if directly applied to the files on the memory stick itself. When i import the photos thru iPhoto 6, I can then use the script on the resulting files in the Finder's iPhoto Library.

Does anyone know why this is? Why am i having the error (which says "can't find year of missing date") when running the script on the original files?

(Tiger 10.4.8 on Intel)

[ Reply to This | # ]