7

I connected a camera to Windows machine through USB, but I am unable to access the device when I type "cd E:\" through command line.

I can see the device through file explorer, and the drive letter appears as E.

The images below illustrate what I am trying to communicate:

Screenshot of command line access window

Windows file explorer at This Computer library contents shows the USB connected device

How can I access a USB connected device storage through Windows command line

0

1 Answer 1

39

Using cd/chdir you cannot change the current working directory (CWD) to one on a different drive unless first switching drives (2 steps) or including the /d switch as part of your command (1 step).

cd /? will display the command's help text.

From C:\Users\jessy to E:\MyData

     2 STEPS
  
1 |  C:\Users\jessy> E:
2 |  E:\> cd \MyData        // also 'cd E:\MyData' & 'cd MyData'
  |  E:\MyData>                         
    

     1 STEP

1 |  C:\Users\jessy> cd /d E:\MyData
  |  E:\MyData>

Credit to Señor CMasMas for pointing out the shorter method.

   

Additional Reading


The way cd deals with drives and directories reflects its roots in DOS. Windows really only has one current directory, however cmd.exe uses environment variables tied to that particular session to set and maintain it's own current directory for each drive separate from Windows as well as any other cmd.exe instances. If you'd like to read more, I have included a few links to get you started.

   

Other Approaches


pushd [ credit: user @printf ]

5
  • 10
    Minor correction: E:\> cd C:\Users\jessy actually changes the "current" directory on drive C: to \Users\jessy -- so even though you're still on drive E:, the following C: command would put you into C:\Users\jessy.
    – Jim Davis
    Dec 5, 2022 at 17:46
  • 2
    Or just start using Powershell already where cd e:\ would work.
    – n0rd
    Dec 5, 2022 at 20:30
  • 3
    Right. The current start of your explanation is confusing at best: what you want to do is explain that cd E:\ changes the current directory for drive E:, but does not change the current drive. The example you give is not bad, but I'd change it to: C:\Users\jessy> E:, E:\> cd c:\ , E:\> c:, C:\>.
    – cjs
    Dec 6, 2022 at 2:39
  • 2
    Lots of fun stuff that's been forgotten. Related to this, a path of E:something.txt refers to a file in the current directory on E:, which may be different from the root :)
    – hobbs
    Dec 6, 2022 at 16:25
  • 1
    Yet another option is to use the pushd command, which can change both drive and directory: pushd E:\ or pushd E:\mydata etc. (You can then later use the popd command to return to the original drive/directory.)
    – printf
    Dec 6, 2022 at 20:01

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