• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: last opened
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: last opened
      • From: Takaaki Naganoya <email@hidden>
References: 
 >last opened (From: Wayne Melrose <email@hidden>)
 >Re: last opened (From: Takaaki Naganoya <email@hidden>)
 >Re: last opened (From: "Mark J. Reed" <email@hidden>)
 >Re: last opened (From: Takaaki Naganoya <email@hidden>)

  • Prev by Date: do shell hanging
  • Next by Date: Re: do shell hanging
  • Previous by thread: Re: last opened
  • Next by thread: Re: last opened
  • Index(es):
    • Date
    • Thread