Setting file creation date in Mac OS X

Solution 1:

You can use SetFile on the command line to do this however it is not included by default in Mac OS X 10.4.x (Tiger). If you have installed the Developer Tools or most of the Combo updates it is installed but in a non standard location. SetFile was included in /usr/bin/ for Mac OS X 10.5 and later.

To find the command you can try using locate to find the location.

Assuming you have the Developer Tools installed:

/Developer/usr/bin/SetFile -d '12/31/2008 12:00:00 PM' nameoffile.txt

You can use another program called GetFileInfo that is installed with SetFile to obtain the modification date.

/Developer/usr/bin/GetFileInfo nameoffile.txt

An example script for one file:

#! /bin/bash
# Usage: nameOfThisScript.sh nameOfFile.txt

modifiedDate=`/usr/bin/GetFileInfo -m $1`
/usr/bin/SetFile -d "$modifiedDate" $1