Re: File creation date in a macro?
Posted by
Wayne Rasband on
Nov 15, 2008; 6:38pm
URL: http://imagej.273.s1.nabble.com/File-creation-date-in-a-macro-tp3694500p3694506.html
> 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 + "'");
File paths with spaces can be handled by using the multiple argument
version of exec():
exec("stat", "-f%c", filepath);
In any case, "stat -f%c" on Mac OS X returns a cryptic 10 digit
number (e.g., "1223733141") that I'm not sure how to interpret. Running
exec("stat", "-l", filepath);
returns a line similar to what you would get using the "ls -l"
command, for example:
-rw-r--r-- 1 wayne staff 76250 Oct 11 09:52:21 2008 /Users/wayne/
IMG_0199.jpg
This is easier to interpret but the date is the date last modified,
not the creation date.
-wayne
> 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.