Finding the name of a USB volume
Richard Gaskin
ambassador at fourthworld.com
Thu Jan 7 10:43:51 EST 2010
Phil Davis wrote:
> Here is an simplified 'system_profiler' output approach. It returns one
> tab-delimited line of info per detachable USB storage device, with all
> the data items known to system_profiler for each device. NOTE: It
> expects system_profiler output to be in English.
>
>
> function macUsbDrives
> -- get USB device info from system profiler
> put shell("system_profiler -detailLevel full SPUSBDataType") into tData
>
> -- convert data to one line per USB device
> replace (colon & cr & cr) with numToChar(245) in tData -- device name
> replace (cr & cr) with numtoChar(250) in tData
> replace cr with tab in tData
> replace numtoChar(245) with (colon & tab) in tData
> replace numtoChar(250) with cr in tData
>
> -- remove records for all but USB drives (English data only)
> filter tData with "*Detachable Drive: Yes*"
>
> -- remove space-padding from items in each line
> set the itemDel to tab
> repeat for each line tLine in tData
> repeat for each item tItem in tLine
> put word 1 to -1 of tItem & tab after tNewData
> end repeat
> put cr into last char of tNewData
> end repeat
> delete last char of tNewData
>
> -- return the data
> return tNewData
> end macUsbDrives
Very helpful Phil, and I appreciate your posting it, but unfortunately
the issue I found with using system_profiler is that it doesn't report
the volume name as it appears to the user on the desktop.
I had hoped there would be some reasonably simple way to get a list of
mounted volumes that looks something like this:
<driveName> <mountPoint> <type>
...where <driveName> is the name as it appears in the Finder,
<mountPoint> is either "/" or "Volumes/<drivename>", and <type> is
either ATA, SCSI, CD/DVD, USB, etc.
With what I've learned in this thread it seems I may be able to use
output from system_profiler checked against output from AppleScript
calls to obtain such a list.
For the future, I see that Jeanne DeVoto had submitted an RQCC request
for "the detailed volumes" which could do what I need if implemented as
described there:
<http://quality.runrev.com/qacenter/show_bug.cgi?id=101>
In the meantime, it looks like I have some parsing to do and some
homework to figure out the details of getting this info for Win Vista,
Win 7, and Linux. I'll post the result here once I get it working.
--
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