windows回到上一次目录和linux不同,没有cd - 命令。
我在这里找到一些答案:http://superuser.com/questions/129969/navigate-to-previous-directory-in-windows-command-prompt
下面的答案可以用在交互情况下,将mycd.bat复制到windows system32目录。
@echo off if '%*'=='' cd & exit /b if '%*'=='-' ( cd /d %OLDPWD% set OLDPWD=%cd% ) else ( cd /d %* if not errorlevel 1 set OLDPWD=%cd% )
然后就可以如下使用:
mycd a\b\c my cd -
Linux情节被满足了。
不过这种用法不能使用在batch scripts中,这时可以使用pushd/popd。
pushd newlisp\win do something ... popd
C:\Users\...\newlisp\win>pushd /? Stores the current directory for use by the POPD command, then changes to the specified directory. PUSHD [path | ..] path Specifies the directory to make the current directory. If Command Extensions are enabled the PUSHD command accepts network paths in addition to the normal drive letter and path. If a network path is specified, PUSHD will create a temporary drive letter that points to that specified network resource and then change the current drive and directory, using the newly defined drive letter. Temporary drive letters are allocated from Z: on down, using the first unused drive letter found.
作者:sheismylife 发表于2013-4-1 15:30:15 原文链接
阅读:62 评论:0 查看评论