Preserve timestamps when copying from FAT to HFS+

Oct 29, '09 07:30:01AM

Contributed by: porg

Imagine you have made a world tour in August 2009 (summer time!) and you have used your digital photo camera to create pictures, videos and voice recordings.

In this guide I will not refer to these items by their specific characteristics (photo, video, audio), but simply regard all of them as "files." Secondly, we assume that the files are saved on a storage medium, which is very likely formatted as FAT (as specified in the DCIM standard for digital cameras).

You have created three files in America/Los Angeles (UTC-0700), three files in your hometown Europe/Vienna (UTC+0200) and three files in Asia/Bangkok (UTC+0700), and at the end of the summer, you return to your hometown Europe/Vienna.

This guide shows you how to correctly bring your files' timestamps from a local time zone-based file system (such as your external flash drive, formatted as FAT32) to a file system using coordinated universal time (UTC) (such as your internal hard disk, formatted as HFS+) using the Finder on MacOS X.

Technical background regarding time stamps:

Some file formats have room for metadata where they can keep temporal data, i.e. JPEG has EXIF. Other file formats may not record any temporal information in the file itself, so the only temporal data which we have then is the file's timestamp in the file system. Some timestamp formats may consider a local time zone when saving, some may consider UTC. And besides this, some may state which time zone they have used, either UTC or another specific local time zone, and some may not state this at all!

Hence a lot of guesswork/uncertainty remains to the consumer level end user, thanks to a suboptimal (or call it worse...) set of technical standards related to digital cameras and time stamps:

Design rule for Camera File system:

Exchangeable image file format (EXIF): Effect on copying between file systems with different time zones:

When FAT (and also EXIF) creates a time stamp, it considers the local time zone of where the file creation occurs! When you later copy a set of file(s) which were all created in the same time zone from a local time zone-based file system (such as FAT) to a UTC-based file system (such as HFS+), the computer cannot know what the time zone of those files was on the local time zone based file system.

If you want to get the correct results, your system time zone must be set to the time zone where the file was created, so that when you copy the file, the correct time zone transformation is performed.

The issue is even more complicated when you create files in different time zones, but on only a single local time zone based file system volume (such as FAT). If you would copy all those files, with their different time zones, at once to a UTC-based file system (such as HFS+), they will all be transformed with the same time zone offset (from their local time zone to the file system's UTC time zone), even though they have different offsets, and therefore some/all might end up with false time stamps.

How to preserve the correct time stamps when copying files:

When copying files from a FAT volume to an HFS+ volume, here's how to preserve the time stamps on the source files:
  1. Process for one set of files originating from the same time zone:
  2. Repeat the process for each additional time zone file set:
  3. Finish the process: After having copied all time zone files, set your system time zone back to your actual physical time zone.
To be noticed after the process:

What is important to understand is that if you watch the files in the Finder, the date/time you see beneath them is the time that it was created in your actual system time zone. This only matches the local date/time of the file creation if it was taken in the same time zone as your system time zone. In all other cases, where the creation time zone is not your system time zone, there will be an offset.

In case you are not sure whether the time stamps are trustworthy, just temporarily set your system time zone to the time zone where the file in question was created. Watch the suspect file(s) in the Finder, and the shown date/time must be the same as the creation date/time. Otherwise, there must have been an error somewhere in your previous manipulation process. After that, turn your system time zone back to your physical time zone, and the display offset will be there again. 2br Mac OS X only displays a valid modification date, and a bogus creation date for files from FAT Volumes. According to this article, FAT saves time stamps for Creation, Modification, and Access. Mac OS X seems to only regard the modification date. This is a bug/issue which is out of the scope of this hint, but I offer some steps for those who are further curious.

I suggest that, after you successfully transfer your files from FAT to HFS+, you copy the files' modification timestamps to the creation timestamps with software such as ABetterFinderAttributes. If you later alter one of those files (i.e. photo editing), its modification date will change, but at the same time, it still has a creation date, allowing you to answer both the questions: When was the file originally created, and when did I manipulate it last?

If you don't take the above step, then you could only know when you edited the filed last, but not when it was originally created. (Except, of course, if you have non-file system information available, such as EXIF data in JPEG picture files.)

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20091014144520112