0

In osx, it is possible to access a hard drive via its label: cd /Volumes/SomeHarddriveLabel

In unix, the same is possible via cd /dev/disk/by-label/SomeHarddriveLabel. This isn't strictly true, you would still need to parse the output like so:

cd $( df /dev/disk/by-label/SomeHarddriveLabel | sed -n 2p | cut -d' ' -f9- )

Is it possible to do this with windows?

1

I think this needs to be scripted:

:: cdrive.bat
@echo off
for /f "skip=1" %%a in ('wmic logicaldisk where VolumeName^="%1" get DeviceID') do (
    %%a 
)

Then:

cdrive label

will switch to the specified drive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.