getting name of startup disk

i’ve been using applescript casually for a while now (makes me sound like a junky…guess i am) and have been stumped by this seemingly easy task. i have some scripts i’m writing that need to be portable to others’ machines regardless of whatever the startup drive is named. now, what’s the best way to set the name of the startup disk to a variable value?
this example works but seems too awkward:

set listDisks to (list disks) as text
set startDisk to item 1 of (list disks) as text

this doesn’t work, throwing up a message saying it can’t get the name of the startup disk:

copy (name of startup disk as text) to x

why doesn’t this work? how can i place the name of the startup disk into a variable? i’ve tried just referencing the “startup disk” in various scripts, but it doesn’t work. this isprobably something simple…anyone?

It should work. Are you using it in a Finder tell block? The name of a diskis a Finder object.

tell application "Finder"
set x to name of startup disk
end tell

You could do it without the Finder:

set x to name of (info for (path to startup disk))

… but this seems to be once instance where the Finder is much faster.NG

Having just reread your post, I think your original ‘list disks’ approach is a good one. It’s faster than the Finder script I’ve just posted, though it does depend on the startup disk’s name always being item 1 of the list. (But I think this might be the case anyway.) As with the Finder script, you don’t need to coerce an item that’s already a string to text.

set startDisk to item 1 of (list disks)


The problem with your script above is that you should not
return your list as text; if you do you will only get the
first letter of the list; instead, return your data as a

set startDisk to item 1 of (list disks) as list

and you will return the value that your’re looking for :slight_smile:

thanks for the responses. i think i have it working in a satisfactory manner.