• 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: Invisible folder "Volumes"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Invisible folder "Volumes"
      • From: Iurista GmbH <email@hidden>
References: 
 >Invisible folder "Volumes" (From: Iurista GmbH <email@hidden>)

  • Prev by Date: Re: Happy New Year! - Filemaker Applescript email help needed
  • Next by Date: Re: Invisible folder "Volumes"
  • Previous by thread: Invisible folder "Volumes"
  • Next by thread: Re: Invisible folder "Volumes"
  • Index(es):
    • Date
    • Thread