Dr. James Colquitt Dr. James Colquitt - 1 year ago 136
R Question

Reading drive Volume Name into R

I'm attempting to perform a task within R based on the Drive Volume Name/Label, however, I can't figure out how to read the drive label in as a variable. I'm not looking for the letter like C:. I need the actual name of the mounted drive, "Bills Computer". Any ideas???


Answer Source

If you are on Windows, something like this should work:

shell("vol C:", intern = TRUE)

After that you can parse the volume name from the output string like that:

s <- shell("vol C:", intern = TRUE)[1]
substring(s, regexpr('is', s) + 3)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download