Finding the name of a USB volume

Richard Gaskin ambassador at fourthworld.com
Wed Jan 6 10:36:33 EST 2010


I'm making a custom installer in which I want to provide the option of a 
normal desktop install to the hard drive and a zero-footprint install to 
a removable USB drive (no registry entries, prefs stored in the app 
folder, etc.).

To help make this simple for the user I'd like to present a list of 
available USB drives if they choose that option, so they can pick the 
target for the install.

Phil Davis was kind enough to share some pointers in his libUsbDrive 
library (see <http://pdslabs.net/usb/index.html>), which has me 
exploring the use of shell calls on OS X to system_profiler, e.g.:

    get shell("system_profiler -xml SPUSBDataType")

While the info returned there contains a lot of very useful stuff, the 
one thing I'm not able to find is the name of the volume as it appears 
to the user on the desktop.

Well, sometimes, that is.

It seems that if I've named the drive in the Finder, the Volumes section 
of the data returned from that shell call is filled in, and includes the 
apparent name of the volume.

But drives which haven't been given a name on a Mac system appear on the 
desktop as "Untitled", and although the data from the system_profiler 
shows it as a removable drive there is no Volumes section included and 
hence no way to know the name of the drive as it appears to the user.

When there is is a Volumes section the _name key there shows the name as 
it appears in the Finder, but drives that have not explicitly been given 
a name appear as "Untitled" or "Untitled 1", etc., in the Finder and the 
corresponding _name key from system_profiler is something different (for 
example my card reader device has a _name value of "Generic USB2.0 card 
" in system_profiler, but on the desktop it appears as "Untitled 1").

Do any of you know a way I can use shell or AppleScript to obtain the 
apparent name of a removable drive when system_profiler fails to return it?

Extra bonus points:  what shell calls would I use to get this info on 
Linux?  I think I have the Windows side of things down, but I'll need to 
work out the Linux side soon.

TIA -

--
  Richard Gaskin
  Fourth World
  Rev training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com
  revJournal blog: http://revjournal.com/blog.irv



More information about the use-livecode mailing list