• 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: Referring to the local hard drive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Referring to the local hard drive


  • Subject: Re: Referring to the local hard drive
  • From: Joseph Briggs <email@hidden>
  • Date: Wed, 03 Jan 2001 21:35:44 -0700

> on 1/3/2001 9:26 AM, Yosemite at email@hidden wrote:
>
>> tell application "Finder" to set thisDisk to name of startup disk as string
>
> This method may be easier to write, but is not very efficient. It depends
> on the Finder, which may or may not be responsive while in the background,
> and is slow because it has to wait on another application to respond.
>
> The following uses AppleScript's text item delimiters to parse the disk name
> from the full textual path. The path to the startup disk is always the disk
> name with a colon added to the end. If you set AppleScript's text item
> delimiters to a colon, and then ask AppleScript for the first text item of
> the path, you'll get the disk name. This method is much faster and is not
> dependant on another application.
>
> set saveDelims to AppleScript's text item delimiters
> set AppleScript's text item delimiters to {":"}
> set diskName to text item 1 of (path to startup disk as text)
> set AppleScript's text item delimiters to saveDelims
> log diskName

I'm kinda new to this, so I can't be exactly sure if I'm right, but couldn't
you also use:

set yourVariable to characters 1 thru -2 of (path to startup disk as text)
as text

This is also independent of the Finder (requires Standard Additions) and
given that the startup disk is every character except the colon of the
startup disk path, this should work. It seems to me, using the delimiters
would be more apt for extracting a second, third, etc., or last text item of
a longer path.


--
Joseph Briggs < email@hidden >
< email@hidden >


  • Follow-Ups:
    • Re: Referring to the local hard drive
      • From: JollyRoger <email@hidden>
    • Re: Referring to the local hard drive
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: Monitoring a folder
  • Next by Date: Re: Monitoring a folder
  • Previous by thread: Re: Referring to the local hard drive
  • Next by thread: Re: Referring to the local hard drive
  • Index(es):
    • Date
    • Thread