Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining a Disk Volume Label in Win32 1

Status
Not open for further replies.

cartw19

Programmer
Feb 11, 2003
8
GB
How do I obtain a disk volume label in a Perl program running under Windows 32.

e.g. I have a CD Rom in my drive d:, how do I find the volume label of the CD Rom?

Any sugestions welcome,
Colin
 
One method would be to use the system's 'vol' command. On my NT box typing

vol d:

produces the following output:

Volume in drive E is perl2
Volume Serial Number is 1C70-9ECA

You could output that to a text file and then use a regex to grab the volume name.
 
This works for me:

@myarray = `vol e:`;
@myarray[0]=~m/\s(\w+)$/;
print "volume is $1\n";
 
For more comprehensive coverage look at Win32::DriveInfo,

Paul
 
Thanks for bringing Win32::DriveInfo to my attention Paul. It works a treat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top