Forum Moderators: coopster

Message Too Old, No Replies

How to read DVD volume name ?

         

knonymouse

8:56 pm on Mar 7, 2009 (gmt 0)

10+ Year Member



It's easy reading filenames, filesize, filedate from a directory with a php script. That includes files on a DVD in an optical drive just as easily.

However, to recognize which disk is in a DVD drive, I want to read the volume name from the DVD, and I have not figured that out. Maybe I'm using the wrong keywords, but I'm not locating any help with Google.

By volume name I mean that which appears in the title bar of a directory window of a DVD or CD drive. It also appears in a Windows directory of "My Computer" next to the drive name. When the drive is empty, it appears as, say, 'DVD Drive (V:)' and when a DVD disk is put in the drive, it instead shows 'This_Disc_Name (V:)' It is the 'This_Disc_Name that I would like to pull into a variable in a PHP script.

knonymouse

3:20 am on Mar 8, 2009 (gmt 0)

10+ Year Member



I solved it when I used keywords "volume label" in a Google search.

The answer is on the php documentation page for shell_exec, and refers to Windows (I'm using the IIS).

[us2.php.net...]

<?php

function GetVolumeLabel($drive) {
// Try to grab the volume name
if (preg_match('#Volume in drive [a-zA-Z]* is (.*)\n#i', shell_exec('dir '.$drive.':'), $m)) {
$volname = ' ('.$m[1].')';
} else {
$volname = '';
}
return $volname;
}

print GetVolumeLabel("c");

?>