Popd and pushd commands in Windows

(Applies to Windows Server (Semi-Annual Channel), Windows Server 2016, Windows Server 2012 R2, Windows Server 2012).

(Applies to Windows Server (Semi-Annual Channel), Windows Server 2016, Windows Server 2012 R2, Windows Server 2012).

Popd command

Change the current directory to the folder stored most recently by the pushd command.For a better understanding of how to use this command, see the example below.

Syntax popd

 Popd 

Popd command parameter

Parameters

Describe

/?

Show help at thecommand prompt.

Popd command comment

  1. Each time you use the pushd command, a single directory will be stored for you to use. However, you can still store multiple directories using the pushd command multiple times. Folders are stored sequentially in a virtual stack. If you use the pushd command once, the directory you use is located at the bottom of the stack. If you use the command again, the second folder is located at the top of the first folder. The process will be repeated every time you use the pushd command. Alternatively, you can use the popd command to change the current directory to the directory stored most recently by the pushd command. If you use the popd command, the folder at the top of the stack will be deleted from the stack and the current directory will be changed to that folder. If you use the popd command again, the next folder on the stack will be deleted.Just like that.
  2. When the command extensions are enabled, the popd command will remove any drive letter assignments created by pushd .

Example popd command

The following example shows how you can use the pushd command and the popd command in abatch program(batch program)to change the current directory from a directory on which the batch program is run.Then change back:

 @echo off 
rem This batch deletes tập tin .txt trong một thư mục đã ghi rõ
pushd% 1
del * .txt
popd
cls
echo các tập tin văn bản đã xóa trong% 1 thư mục

Pushd command

Store the current directory for use by the popd command, and then change the specified directory.For a better understanding of how to use this command, see the example below.

Syntax pushd command

 pushd [] 

Pushd command parameter

Parameters

Describe

 

Specify the directory to create the current directory.This command supportsrelative paths.

/?

Show help at thecommand prompt.

Pushd command comment

  1. Each time you use the pushd command, a single directory is stored for you to use. However, you can also store multiple directories using the pushd command multiple times. Folders are stored sequentially in a virtual stack. If you use the pushd command once, the directory you use is located at the bottom of the stack. If you use the command again, the second folder is located at the top of the first folder. The process will be repeated every time you use the pushd command.
  2. Alternatively, you can use the popd command to change the current directory to the directory most recently stored by the pushd command. If you use the popd command, the folder at the top of the stack will be deleted from the folder. The current directory and directory will be changed to that folder. If you use the popd command again, the next folder on the stack will be deleted.Just like that.
  3. If the command extension is enabled, the pushd command will accept either the network path or the local drive letter and path.
  4. If you specify a network path, the pushd command temporarily assigns the highest unused drive letter (starting with Z :) to the specified network resource. The command then changes the current drive and directory to the specified folder on the newly assigned drive. If you use the popd command with extended command utilities enabled, the popd command will delete the drive letter created by pushd .

Example pushd command

The following example shows how you can use the pushd command and the popd command in abatch program(batch program)to change the current directory from a directory on which the batch program is run.Then change back:

 @echo off 
rem This batch deletes tập tin .txt trong một thư mục đã ghi rõ
pushd% 1
del * .txt
popd
cls
echo các tập tin văn bản đã xóa trong% 1 thư mục

See more:

  1. Netcfg command in Windows
  2. Nbtstat command in Windows
  3. Bitsadmin create command in Windows
  4. The nlbmgr command in Windows
Update 26 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile