Re: Message -ID, email@hidden, Back and forth between Posix and HFS paths
Re: Message -ID, email@hidden, Back and forth between Posix and HFS paths
- Subject: Re: Message -ID, email@hidden, Back and forth between Posix and HFS paths
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 29 Mar 2010 18:41:36 -0400
On Mon, Mar 29, 2010 at 6:08 PM, Alex Zavatone <email@hidden> wrote:
> Am urgently looking for a shell script "to find the last modified file in a
> folder AND its subfolders"
There's no simple shell one-liner for that. You can build a solution
using the find(1) command, or some other programming language. In
Perl you can make it a one-liner, but it's not exactly simple:
do shell script "perl -MFile::Find -e 'find(sub { $mtime =
(lstat($_))[9]; $newest = [$File::Find::name, $mtime] if (!$newest ||
$mtime > $newest->[1]); }, shift); print $newest->[0]' " & (quoted
form of POSIX path of startFolder).
Replace the lstat() with stat() if you want to follow symbolic links
to get the mtime on the target, but then you might get an unexpected
failure with symlinks that don't resolve, which the above code doesn't
have to take into account.
> Have tried with success a doubleĀ "ls -1t " (.ie first identify the newest
> folder, then identify the newest file in that folder)
That's not valid - the most recently modified file may not be in the
most recently modified folder. Modify dates are not recursive;
modifying a file in a folder does not show up as modifying the folder
itself. Only adding or deleting or renaming a file causes the
folder's modification time to be updated.
--
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