Login  Register

Re: File creation date in a macro?

Posted by dscho on Nov 15, 2008; 2:32pm
URL: http://imagej.273.s1.nabble.com/File-creation-date-in-a-macro-tp3694500p3694505.html

Hi,

On Sat, 15 Nov 2008, Norbert Vischer wrote:

> here is a macro that extracts the creation date via AppleScript. It has
> been partly created with my AppleScript Wrapper (see
> http://simon.bio.uva.nl/AppleScript/AppleScriptWrapper.html ) It only
> works on the startup volume - perhaps some AppleScript expert can tell
> me how to remove this limitation.

I am by no means an expert in AppleScript, but Wayne was so kind to remind
me that the macro function "exec()" _can_ execute programs.

So this should work on Mac:

        exec("stat -f %c " + filename);

and this on Linux:

        exec("stat -c %Z " + filename);

Note that this will not handle filenames with spaces correctly, you will
have to write something as ugly as this if you have such filenames:

        exec("stat -c %Z '" + filename + "'");

Ciao,
Dscho

P.S.: I am pretty certain that there is also some program on Windows that
can tell you the creation date, but Windows has a track record of changing
the set of available commands from time to time, so that may break.