Search code examples
macosmountdvd

OS X: which volume is a DVD?


How can I programmatically determine which (if any) mounted volumes are a DVD?

I currently look for a directory with permissions 555 but I would prefer something a bit less hacky. Thanks!!

$ ls -l /Volumes/
total 12
dr-xr-xr-x  4 mh    gfx    136 Aug  3  2001 DQRMX2102
lrwxr-xr-x  1 root  admin    1 Apr  6 15:09 Macintosh HD -> /
drwxrwxr-x  9 mh    gfx    374 Feb  3 12:55 data

Solution

  • What programming language/toolkit are you using?

    If you're using Cocoa in Objective-C, you can NSWorkspace:

    NSArray *volumes = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
    

    If you want to find out from the command line or a script or something, diskutil should come in handy.

    $ diskutil info -plist /Volumes/Foobar
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    ...snip...
        <key>OpticalMediaType</key>
        <string>CD-ROM</string>
    ...snip...
    </dict>
    </plist>