Pushd & Popd

I had the need to write a script that make some directories changes but at the exit came back to the current directory where I ran it.

The pushd command saves the current working directory so it can be returned to at any time, optionally changing to a new directory. The popd command returns to the path at the top of the directory stack.

In Windows PowerShell, pushd is a predefined command alias for the Push-Location cmdlet and popd is a predefined command alias for the Pop-Location cmdlet.

This directory stack is accessed by the command Get-Location -stack in Windows PowerShell.

pushd and popd is available also on windows command prompt (CMD) and Linux bash.

Example:

PS C:\> pushd .\Data\Working\
PS C:\Data\Working> Get-Location -Stack

Path
----
C:\

PS C:\Data\Working> popd
PS C:\>

 

Via: https://technet.microsoft.com/en-us/library/bb490978.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s