如何使用cmd.exe返回上一个目录?

Jic*_*hao 16 windows shell command-line

可能的重复:
Windows 命令行可以支持 Linux “cd -”吗?

在Linux下,我可以使用cd -返回到最后一个目录。我怎么能在 Windows 上做到这一点?

Xet*_*ius 24

您可以使用 pushd 和 popd 命令。

  • pushd <dir> 将目录从位置 a 更改为位置 b
  • popd 将目录改回目录a

例子:

pushd %TEMP%     // go to user's temp dir, and remember
pushd \Windows   // go to windows dir, and remember
popd             // go back one dir, in this case the temp dir
popd             // go back one more dir, in this where you were before temp
Run Code Online (Sandbox Code Playgroud)


小智 6

Cmd.exe 是旧 MS-DOS 的模拟层,命令相同:

  1. 后退一步= cd..
  2. 全部向后 = cd /

对于其他人,请查看网络上的一些 Ms-Dos 表

  • 这不是 cd - 所做的。如果其中一个在 /a/b/c/d 中,则 cd 到 /a/e/f,“cd -”作为命令将返回到 /a/b/c/d,而“cd ..”会将您移动到/a/e 和 `cd /` 将您移至 /。 (5认同)