I have a large amount of files that i need modify the creation date, but the dates i have are in epoch time. any suggestions for doing this via applescript?
I don’t think this can be done in plain applescript. Unix epoch time is the number of leap less seconds since 1/1/70, GMT, so it’s a big number. To see the current Unix time do this:
set N to current date --> "Saturday, July 8, 2006 9:40:13 PM" -- just for comparison
set ET to do shell script "date +%s" --> "1152405613", the Epoch time for Unix as string.
-- PROBLEM: if you convert that to a number, it's this: 1.152405733E+9
It looks like this is a shell script or Perl script job and I can’t help you with either. There are Java and JavaScript tools for doing this too.
Hope someone else can help. At first I thought to subtract 946684800 (1/1/2000) from the number, but had no luck.
Hi,
I don’t understand how the creation date can be in unix epoch time and don’t now about that much, but can’t you just add the seconds to the epoch. e.g.
set e to date “Thursday, January 1, 1970 12:00:00 AM”
set d to (current date) – current date instead of the creation date
set ET to d - e
return (e + ET)
gl,
Hi Kel;
I think that gjs wanted to recover the original date stamp as a date and then change the mod date of the file to an Apple date. He would have had time stamps if the originals were created in a unix system.
Hi Adam,
I think that op Greg wanted to set the creation date by looking at something but what that something is I don’t know. Maybe he’ll write back.
Have a good one,
Here’s if you want local time:
set ET to do shell script "date +%s"
set n to ET as number
set t to "1/1/1970"
set e to date t
set mod_date to (e + n) + (time to GMT)
gl,