Dr. James Colquitt Dr. James Colquitt - 1 month ago 5
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???



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)