同时更改驱动器和目录

To change drive and directory at the same time

您好,目前我经常使用命令提示符。每次我需要访问不同驱动器的不同文件夹所以我需要同时更改驱动器和目录为此我得到了一个解决方案: C:> CD /D D:\JAVA 它工作正常。但是为什么我们使用“/D”

那么请解释一下我们为什么使用 /D。

cd /? 会为您解答。

cd /d d:\java 的替代方法是 d: 然后 cd java。如果您随后更改为另一个驱动器(比如 C:)和 运行 dir d:,您仍然会看到 java 目录的内容。即 OS 记住每个驱动器当前正在查看的目录。同样,您可以只 运行 C:>cd d:\otherDir c:>dir d: 并查看 otherDir.

的内容

CD /D ... 除了更改文件夹外,还更改当前 驱动器


来源CD Change Directory - Select a Folder (and drive)

Syntax

  CD [/D] [drive:][path]
  CD [..]

Key

/D : change the current DRIVE in addition to changing folder.

...

Changing the Current drive

Enter the drive letter followed by a colon.

C:> E:
E:>

To change drive and directory at the same time, use CD with the /D switch.

C:> cd /D 
E:\utils E:\utils\>

通过使用命令 -

CD [/D] [drive:][path]

on cmd 表示跳转到不同的目录 其中/D只是表示跳转到另一个目录。与 cd [drive:][path] 命令不同,此命令 还可以自由使用不同的驱动器

通过使用上述命令,只需在驱动器名称后跟一个冒号,就可以移动到特定驱动器中相同的先前工作目录。例如:

C:\Users>cd /D G:\FUN

G:\FUN>C:

C:\Users>