POPD: Restores the previous value of the current directory saved by PUSHD.


 


... The examples for the command "POPD"
... "POPD" Excerpt from Microsoft Windows Help
... Important information, tips for the "POPD" command

The command: "POPD" is on Windows 11, 10, .. , MS Server 2025, 2022, 2019, .. available

The examples for the command "POPD"

The `POPD` command in Windows Command Prompt is used to go to the last saved directory (which was saved by `PUSHD`). Here are some examples of using the `POPD` command: Example 1: Using PUSHD and POPD:

REM Change to the "C:\Example" directory
PUSHD C:\Example

REM Show the current working directory
ECHO Current directory: %CD%

REM Change back to the original directory
POPD

REM Show the current working directory again
ECHO Current directory: %CD%

Description: In this example, `PUSHD` is used to change to the “C:\Example” directory. The current working directory is then displayed with `%CD%`. Then use `POPD` to return to the original directory and the working directory will appear again. Example 2: Using PUSHD and POPD in a loop:

REM loop through directories and perform actions
FOR /D %%G IN (C:\Directory\*) DO (
  PUSHD "%%G"
  ECHO Current directory: %CD%
  REM Execute actions in the current directory here
  POPD
)

Description: This example cycles through all subdirectories of "C:\directory\". For each subdirectory, the current working directory is displayed and then `POPD` is used to return to the original directory. Example 3: Using PUSHD and POPD in a batch script:

@ECHO OFF
REM Save the current directory
PUSHD C:\My\Script\Directory

REM Execute actions here in the desired directory
ECHO Current directory: %CD%

REM Return to the original directory
POPD

Description: In this batch script, the current directory is saved using `PUSHD`, actions are performed in the desired directory, and finally the original directory is returned using `POPD`. Note: Note that `POPD` only works if `PUSHD` was previously used to save a directory. Otherwise it will give an error message. `PUSHD` and `POPD` are useful when you want to temporarily change to a directory and then return to the previous directory without having to manually save the full path.

"POPD" Excerpt from Microsoft Windows Help

Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.

C:\\WINDOWS>

Changes to the directory stored by the PUSHD command.

POPD


If Command Extensions are enabled the POPD command will delete
any temporary drive letter created by PUSHD when you POPD that
drive off the pushed directory stack.

Important information, tips for the "POPD" command

There are a few important points to note when using the `POPD` command in the Windows Command Prompt: 1. Previous Directory: `POPD` returns to the previous directory saved by `PUSHD`. Therefore, it is important to ensure that `PUSHD` has been previously used to save a directory. 2. Error if not saved: If `PUSHD` has not been previously used to save a directory, calling `POPD` will result in an error message. Make sure `PUSHD` was used in the script or session before running `POPD`. 3. Order of `PUSHD` and `POPD`: Note the order of `PUSHD` and `POPD`. The directory will be restored to the state it was in when `PUSHD` was called. 4. Use in loops and batch scripts: `POPD` is particularly useful in loops or batch scripts when you want to temporarily change to a directory and then return to the original directory. 5. Use with absolute paths: `PUSHD` stores the absolute path to the current directory. Keep this in mind when working with absolute paths. 6. Use in subprocesses: Note that `PUSHD` and `POPD` perform the directory change only in the current process. If you call a batch script from within another batch script, the directory change cannot be maintained between scripts. 7. Nested directory changes: If you use `PUSHD` multiple times in a row, you can use `POPD` the same number of times to return to the original directory.

PUSHD C:\Directory1
PUSHD D:\Directory2
REM ... actions in directory2 ...
POPD
REM ... actions in directory1 ...
POPD

8. Batch file extensions: Note that `POPD` typically does not work in a script invoked directly from the command prompt. It is more likely to be used in batch files (`.bat` or `.cmd`) or in the command prompt itself. Keep these points in mind to ensure you use `POPD` effectively in your batch scripts or when using the Command Prompt.


Deutsch
English
Español
Français
Italiano
日本語 (Nihongo)
한국어 (Hangugeo)
汉语 (Hànyǔ)
Türkçe
Português
Português
Svenska
Norsk
Dansk
Suomi
Nederlands
Polski









Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



The command POPD - Restores the previous value of the current directory saved by PUSHD.

HTTP: ... console/en/047.htm
0.108
18045
Datenübertragung zu langsam. W10 Defender aktiviert sich immer wieder! Ctrl+Alt+Delete when signing in on Windows 11 or 10! Can I run the ColorConsole as an administrator? Windows desktop in the foreground at click doesn't work? New save options for custom text (wildcards), can I? Machen SSD Festplatten Geräusche? Convert File Name to File Time Stamp - Example Android Smartphones! My Computer and This PC, where is the difference? Where can I find the Windows 11 version and build number? Is it possible to roll back a Windows driver?



(0)