• 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: HD name change for X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HD name change for X


  • Subject: Re: HD name change for X
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 17 Jan 2002 17:35:29 -0800

On Thursday, January 17, 2002, at 02:55 PM, Michelle Steiner wrote:

On 1/17/02 9:15 AM, nino <email@hidden> quoted:

Once I do come up with the new name, is there an Applescript method of
quickly changing my existing scripts which have "Mac Hard Drive" as part of
filepaths, etc., so that they will incorporate the new name?

This is a good time to point out (unless someone else has already pointed
it; in which case it's redundant) that it would be good to declare the
disk name as a global variable at the beginning of the script. That way,
there would be only one place where it needs to be entered.

Maybe even better is to store it as a property, and have the user choose
the disk the first time the script is run on that disk. Then the name
won't have to be entered in the script at all.

And even better than that would be to exploit the Finder's magic folder references or "path to" so you don't even need to ask for the disk name. If you want to grab a file named "Bob's Prefs" in the preferences folder, the correct way is not this...

file "My Hard Drive:System Folder:Preferences:Bob's Prefs"

...or this...

file "System Folder:Preferences:Bob's Prefs" of the startup disk -- inside a Finder tell
file ((path to startup disk as string) & "System Folder:Preferences:Bob's Prefs") -- or outside

...it's this:

file "Bob's Prefs" of the preferences folder -- inside a Finder tell
file ((path to preferences folder as string) & "Bob's Prefs") -- or outside.

The first will only work on your machine, the second will work many people's classic Mac OS systems, but the third will work anywhere. Mac OS in general and AppleScript in particular define a lot of interesting folders in abstract terms, so don't use paths unless you have to -- they're brittle.


--Chris Nebel
AppleScript Engineering

(I'm sure someone will point out that "file" references don't always do the right thing, and that you might need to use "alias" instead. Yes, I know -- the point here is to use the meta-folders.)


  • Prev by Date: Re: How to grab Now calendar categories & choose in dialog?
  • Next by Date: Smile 1.8.7 update problem
  • Previous by thread: Re: HD name change for X
  • Next by thread: Re: HD name change for X
  • Index(es):
    • Date
    • Thread