popd

popd 指令會將現行目錄變更為 pushd 指令最近儲存的目錄。

每次使用 pushd 命令時,都會儲存一個目錄供您使用。 不過,您可以多次使用 pushd 指令來儲存多個目錄。 目錄會循序儲存在虛擬堆疊中,因此如果您使用一次 pushd 指令,則您使用該指令的目錄會放在堆疊的底部。 如果您再次使用該命令,則會將第二個目錄放在第一個目錄的上方。 每次使用 pushd 指令時,都會重複此程序。

如果您使用 popd 指令,則會移除堆疊頂端的目錄,並將目前目錄變更為該目錄。 如果您再次使用 popd 指令,則會移除堆疊上的下一個目錄。 如果啟用指令延伸, popd 指令會移除 pushd 指令所建立的任何磁碟機代號指派。

Syntax

popd

Parameters

Parameter Description
/? 在命令提示字元顯示說明。

Examples

若要從執行批次程式所在的目錄變更目前目錄,然後再改回來,請輸入:

@echo off
rem This batch file deletes all .txt files in a specified directory
pushd %1
del *.txt
popd
cls
echo All text files deleted in the %1 directory