Hi,
touch -t can change the creation date, but it can only set backward, not forward.
Here is a AppleScript that uses the class NSFileManager from the Foundation framework to change the file's creation date.
-- this script set the creation date of each file to the file's modification date
-- When the dialog will appear, just select the files whose creation date is incorrect.
set pathErr to getFiles()
if pathErr is not "" then -- if error on some file
activate
display dialog "Done, but the creation date of some files have not been changed"
tell application "TextEdit"
activate
make new document at end of documents with properties {text:(" The creation date of these files have not been changed :" & pathErr)}
end tell
else
display dialog "The creation date of all the files have been changed."
end if
on getFiles()
script o
property tFiles : {}
end script
set o's tFiles to choose file with multiple selections allowed without invisibles
set t to ""
set tError to ""
set tc to count o's tFiles
repeat with i from 1 to tc
set t to t & " " & quoted form of POSIX path of (item i of o's tFiles)
if (i mod 250) = 0 or i = tc then -- 250 files sent to the shell to not exceed the limit of characters.
set r to my setCreationDateToModDate(t)
if r is not "" then set tError to tError & return & r
set t to ""
end if
end repeat
return tError
end getFiles
on setCreationDateToModDate(theseFiles)
do shell script "/usr/bin/env python -c 'import os, sys
from Foundation import NSFileManager
df = NSFileManager.defaultManager()
nbr=len(sys.argv)
for i in range( 1, nbr ):
f = sys.argv[i]
my_dict, error = df.attributesOfItemAtPath_error_(f, None)
if error is None:
mDate = my_dict.fileModificationDate()
cDateDict = {\"NSFileCreationDate\":mDate}
b, error = df.setAttributes_ofItemAtPath_error_(cDateDict , f, None)
if not b: print f' " & theseFiles
end setCreationDateToModDate
Works on OS X 10.5.x or newer.