• 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: file with most recent modification date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file with most recent modification date


  • Subject: Re: file with most recent modification date
  • From: John <email@hidden>
  • Date: Tue, 26 Nov 2013 10:11:29 -0500

Test it with a folder with three files and then modify the oldest one.

JD


On Tue, Nov 26, 2013 at 10:02 AM, Emmanuel LEVY <email@hidden> wrote:
I vaguely remember that "find" uses an index which is not always up to date - isn't it updated on saturdays at 3 am?

Emmanuel

On Nov 26, 2013, at 3:45 PM, John wrote:

> Hi Shane,
>
> This is what I use to recursively sort files...
> set folderPath to POSIX path of (choose folder)
>
> set latestFiles to paragraphs of (do shell script "find " & quoted form of folderPath & " -type f -flags nohidden \\! -name \".*\" -exec stat -f \"%Sm - %N\" -t \"%Y-%m-%d %H:%M:%S\" {} + | sort -r ;")
>
> I wrote this script to reveal the latest file in the frontmost Finder window. Map it to a keystroke or create a service for quick access.
>
> https://dl.dropboxusercontent.com/u/2422542/Reveal_Recent.zip
> John Day
>
>
>
> On Tue, Nov 26, 2013 at 6:34 AM, Shane Stanley <email@hidden> wrote:
> On 26 Nov 2013, at 8:42 PM, Emmanuel LEVY <email@hidden> wrote:
>
> > Maybe stating the obvious, I recall that the shell command "ls" supports a "-t" option to sort by modification date:
> >
> >>     -t      Sort by time modified (most recently modified first) before sort-
> >>             ing the operands by lexicographical order.
> >
> > For scripters not familiar, that would give:
> >
> > do shell script "ls -t " & (quoted form of (posix path of theFolderAsAlias))
> >
> > More info is returned with, for instance the "l" option:
> >
> > do shell script "ls -tl " & (quoted form of (posix path of theFolderAsAlias))
>
> You raise a very good point. And it's faster (unless you include the l option). But it doesn't actually do the same job, which was to sort the *files*.
>
> You can add a -p and pass it through grep to remove directories, but unfortunately that also removes files that are packages. Being a Unix utility, ls doesn't distinguish between directories and packages. And if you do it recursively, not only can't you stop it from listing the contents of packages, but you also end up with the challenge of rebuilding the full file paths from the various fragments returned.
>
> That's not to say ls isn't without its uses -- I've used it for years, gratefully -- but it does have its limitations.
>
> --
> Shane Stanley <email@hidden>
> <www.macosxautomation.com/applescript/apps/>
>
>
>  _______________________________________________
> 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
>
> _______________________________________________
> 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


 _______________________________________________
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

 _______________________________________________
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

References: 
 >file with most recent modification date (From: Robert Poland <email@hidden>)
 >Re: file with most recent modification date (From: Luther Fuller <email@hidden>)
 >Re: file with most recent modification date (From: Robert Poland <email@hidden>)
 >Re: file with most recent modification date (From: Shane Stanley <email@hidden>)
 >Re: file with most recent modification date (From: Shane Stanley <email@hidden>)
 >Re: file with most recent modification date (From: Emmanuel LEVY <email@hidden>)
 >Re: file with most recent modification date (From: Shane Stanley <email@hidden>)
 >Re: file with most recent modification date (From: John <email@hidden>)
 >Re: file with most recent modification date (From: Emmanuel LEVY <email@hidden>)

  • Prev by Date: Re: AppleScript Reference Library
  • Next by Date: Re: Paths from my Mac, hidden, compiled into my script?
  • Previous by thread: Re: file with most recent modification date
  • Next by thread: Re: file with most recent modification date
  • Index(es):
    • Date
    • Thread