Re: Invisible folder "Volumes"
Re: Invisible folder "Volumes"
- Subject: Re: Invisible folder "Volumes"
- From: Ron Hunsinger <email@hidden>
- Date: Sun, 01 Jan 2012 22:04:16 -0800
On Jan 1, 2012, at 5:21 PM, Iurista GmbH wrote:
> Hi
>
> does anyone know, why the folder "Volumes" of startup disk behaves otherwise than the other invisible folders on top level.
> My test script looks as follows:
> ===========
> tell application "Finder"
> activate
> set FW1 to Finder window 1
> set TG to target of Finder window 1
>
> set TheList to {}
> set oldDelims to AppleScript's text item delimiters
> set AppleScript's text item delimiters to {":"}
> repeat with i from 1 to (number of text items) of (TG as text)
> set TheList to TheList & text item i of (TG as text)
> end repeat
> set AppleScript's text item delimiters to oldDelims
> end tell
>
> return TheList
> ===========
> If any of the folders "usr", "bin", "sbin", "cores", "private", ".vol" is frontmost, the script correctly returns {"Startdisk_name", "the_foldername", ""}. If "Volumes" is frontmost, the script returns {"", ""}
>
> How comes?
I'm not entirely sure why, but it probably has to do with the fact that (disk "XYZ") has POSIX path "/Volumes/XYZ" and HFS path "XYZ:". Drop "XYZ" from all that, and (disk ""), if there were such a thing, would have POSIX path "/Volumes/" and HFS path ":". That is, Finder sees folder "Volumes" as the name of a disk whose name you forgot to mention, and turns it into an HFS path whose disk name is missing.
If you change
(TG as text)
to
(TG as alias as text)
then it works as expected. This isn't the only place where Finder objects (files and folders) can't be coerced directly to text, but have to go through some intermediate form (usually alias) to get the correct result.
BTW:
set TheList to {}
repeat with i from 1 to number of text items of (TG as alias as text)
set theList to TheList & text item i of (TG as alias as text)
end repeat
can be written more simply and much more efficiently as
set TheList to text items of (TG as alias as text)
-Ron Hunsinger _______________________________________________
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