How to return to last directory with cmd.exe?

12

2

Possible Duplicate:
Can windows command line support Linux “cd -”?

Under Linux, I can use cd - to return to the last directory. How can I do that on Windows?

Jichao

Posted 2009-12-18T10:03:11.813

Reputation: 5 245

Question was closed 2009-12-18T11:12:56.087

1

Duplicate of this question: http://superuser.com/questions/81755/can-windows-command-line-support-linux-cd

– Snark – 2009-12-18T10:12:02.497

Answers

19

you can use the pushd and popd commands.

pushd will change directory from location a to location b popd will change directory back to directory a

Xetius

Posted 2009-12-18T10:03:11.813

Reputation: 1 151

It doesn't work for me, but using cd.. works, thanks to @Акула (below answer)

– Mehdi Dehghani – 2017-07-06T06:14:28.413

5

Cmd.exe is an emulation layer for the old MS-DOS, commands are the same :

  1. One step backward = cd..
  2. All Backward = cd /

For the others look at some Ms-Dos table around the web

Акула

Posted 2009-12-18T10:03:11.813

Reputation: 183

2This is not what cd - does.

If one is in /a/b/c/d then cd's to /a/e/f, cd - as a command returns you to /a/b/c/d, whereas cd .. moves you to /a/e and cd / moves you to /. – Neal – 2009-12-18T15:18:35.983

You are right i've misunderstanded the question. (What poor figure!) :-( – Акула – 2009-12-18T15:39:48.740