Re: file with most recent modification date
Re: file with most recent modification date
- Subject: Re: file with most recent modification date
- From: Shane Stanley <email@hidden>
- Date: Tue, 26 Nov 2013 22:34:06 +1100
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