Re: last opened
Re: last opened
- Subject: Re: last opened
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 22 Mar 2007 11:38:42 -0400
On 3/22/07, Takaaki Naganoya <email@hidden> wrote:
Mark, I comfirmed they return same date.
That's what I thought. I know HFS+ has a creation time separate from
the Unix ctime, but in the case of atime it doesn't make much sense to
do that.
So, your way is smarter and faster than mine.
Faster, maybe. Smarter, not necessarily. I was just curious about
the date equivalence question.
If you're going to use ls, be advised that the date format output by
"ls -l" varies with how long ago the timestamp is. Within the past
year, it's dd Mon HH:MM; before that, it's dd Mon yyyy:
-rw-rw-r-- 1 mreed admin 0 22 Mar 2006 bar
-rw-rw-r-- 1 mreed admin 0 22 Mar 11:24 foo
The best way to get parseable timestamps out of ls is to use the -T
option, which forces the complete date and time to be included for all
files:
-rw-rw-r-- 1 mreed admin 0 22 Mar 11:24:00 2006 bar
-rw-rw-r-- 1 mreed admin 0 22 Mar 11:24:24 2007 foo
But there are better ways of getting file timestamps. I'd be
surprised if the Finder didn't offer this information in its AS dict,
but even within the "do shell script" realm, you can use Perl (or
Python/Ruby/Tcl) to get the timestamp in a more processing-friendly
form:
do shell script "perl -MFile::stat -le 'print stat(" &
quoted form of POSIX path of
myFile & ")->atime)'"
--> 1143044640
That gets you the raw timestamp value in seconds since 1970. You can
also ask Perl to format it for you:
do shell script "perl -MFile::stat -MPOSIX -le 'print strftime(\"%FT%T\",
localtime(stat(" & quoted form of POSIX path of
myFile & ")->atime))'
--> "2006-03-22T11:24:00"
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden