In windows cmd there is no 'cd - ' where in Linux which means return to the last visited directory
however, you can make some alias in such as way
@echo off
if '%*'=='' cd & exit /b
if '%*'=='-' (
cd /d %OLDPWD%
set OLDPWD=%cd%
) else (
cd /d %*
if not errorlevel 1 set OLDPWD=%cd%
)
and may use doskey macro to do some alias
C:\>doskey cd=mycd $*
The only caveat is if you omit the space between cd
and ..
or \
, you will get the builtin version ofcd
not the doskey
macro... and you still have to remember not to use C:
, D:
etc. to change drive.
Please refer to the origianl discussion on "Navigating to Previous directory in Windows Command Prompot" from StackOverflow.