Re: Back and forth between Posix and HFS paths
Re: Back and forth between Posix and HFS paths
- Subject: Re: Back and forth between Posix and HFS paths
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 26 Mar 2010 13:34:49 -0400
That will fail for directories where the list of full paths of the
items is too long (some a combination of a large number of items
and/or a long root pathname), btw, though it should be fine on your
174-item folder if the folder itself isn't too deep in the filesystem.
But you can make it more robust by removing the wildcard and manually
assembling the full paths:
repeat with posixPath in paragraphs of (do shell script "ls -1t " &
(quoted form of POSIX path of containingFolder))
set end of itemList to (POSIX path of containingFolder) & posixPath
end repeat
It's also non-recursive; it only lists the top-level contents of the
folder. If the folder has subfolders and you want to get the contents
of them all the way down, with the whole thing sorted, that's more
complicated. But your Finder version was using "items of" instead of
"entire contents of", so this is the same result.
On Fri, Mar 26, 2010 at 1:05 PM, Mark J. Reed <email@hidden> wrote:
> You could try this:
>
> set itemList to {}
> repeat with posixPath in paragraphs of (do shell script "ls -1td " &
> (quoted form of POSIX path of containingFolder) & "/*" )
> set end of itemList to POSIX file posixPath
> end repeat
>
> That will get you a list of actual AppleScript file objects, sorted by
> modification date, that you can then do whatever you want with.
>
> Change the "ls -1td" to "ls -1tdr" if you want them sorted in the other order.
>
>
>
>
> On Fri, Mar 26, 2010 at 12:20 PM, Alex Zavatone <email@hidden> wrote:
>> Wow. How remarkably non intuitive.
>> In any case, that rocks Mark. I have to account for users putting funny file names into their folders.
>>
>> The deal is that the lovely approach of getting the sorted directory listing that I asked about yesterday takes 15 seconds for a directory of 174 items on a Quad Intel box under 10.6.whatever, while doing it from Unix is rather instant.
>>
>> Also, we have some boxes running 10.4 server and 10.5 and sadly, the Finder's sort does not work on 10.4.
>>
>> In any case, I'll post the Unix result if I get it working.
>>
>> Thanks again man
>>
>> Cheers,
>> - Alex
>>
>> On Mar 26, 2010, at 10:47 AM, Mark J. Reed wrote:
>>
>>> POSIX file "unix path goes here" as string
>>>
>>> There are no non-UNIX-friendly characters in that filename, by the
>>> way. The only character you can't have in a UNIX filename is a slash.
>>> Your filename isn't particularly typing-at-the-command-line-friendly
>>> (since it's hard to type a ™ and you have to quote the thing), but
>>> really, there's no problem in UNIX with such files.
>>>
>>
>>
>
>
>
> --
> Mark J. Reed <email@hidden>
>
--
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