Under windows, identify a drive by partition label, not only the drive letter to allow using the same PATH (M:\music) for instance for different drives.
Get label:
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec("cmd.exe /c dir d:");
BufferedReader? br = new BufferedReader?(new InputStreamReader?(p.getInputStream()));
String volume = br.readLine();
Matcher matcher = Pattern.compile("(\\s)*Volume in drive \\w is (\\w|\\p{Punct})*").matcher(volume);
if (matcher.find())
{
volume = volume.substring(matcher.start(), matcher.end());
volume = volume.replaceAll("(\\s)*Volume in drive \\w is ","");
} else if (Pattern.compile("Volume in drive \\w has no label").matcher(volume).find())
{
volume = null;
}