PUSHD & POPD to navigate directories temporarily in DOS command line
If you're new here, you may want to subscribe to our RSS feed. Thanks for visiting!
If you are a heavy Command Prompt (DOS) user, this might well be a very useful tip. In the DOS prompt, the most commonly used command would be cd (change directory) to switch between directories that you work. If you working between more than one directory (say C:\Documents and Settings\username\desktop) and (say C:\Windows\system32) then everytime you change between direcories using the cd command, you need to type in the path as well (atleast I feel its not friendly).
Well here is a solution, Windows has the PUSHD & POPD DOS commands that help you navigating between these directories. PUSHD/POPD are great tools when navigating between directories and shares temporarily. PUSHD & POPD commands are the unix equivalents which can remember the directories that you navigate in the memory as Last IN First Out (LIFO). So, when you navigate between multiple directories and then need to comeback one step or two, you can simply comeback using one single command.
Say for instance in the following:
P:\>pushd “c:\Documents and Settings\”
C:\Documents and Settings>pushd c:\WINDOWS
C:\WINDOWS>pushd c:\WINDOWS\system
C:\WINDOWS\system>pushd c:\WINDOWS\system32
When the above happens, everytime you change directory using the pushd command instead of the “cd” then it adds it to the memory and jump to the directory. Thats good news. but, how do you come back? there comes POPD
C:\Documents and Settings>pushd c:\WINDOWS
C:\WINDOWS>pushd c:\WINDOWS\system
C:\WINDOWS\system>pushd c:\WINDOWS\system32
C:\WINDOWS\system32>popd
C:\WINDOWS\system>popd
C:\WINDOWS>popd
C:\Documents and Settings>popd
P:\>
There you go, it took you back one step at a time back to where you started.
PUSHD/POPD can help you to temporarily add a network share and assign it a drive letter and coming out and clearing the share is simple. The assignment of drive letters in reverse order from “Z” (picks unused drive letter from the last)
Example:
To naavigate to a share and assign a drive letter
C:\>pushd \\fileserver\shared-docs\
Z:\shared-docs>
To come back and clear the share
Z:\shared-docs>popd
C:\>
C:\>Z:
The system cannot find the drive specified.C:\>
Related Post
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically each day to your feed reader.






















Your description was exactly what I needed (and exactly what I hoped to read, being accustomed to linux scripting). Only one minor issue: I think you meant that PUSHD and POPD operate on a “stack” or LIFO queue, rather than a FIFO.
Thanks again,
Stu.
You are right! It indeed is LIFO.
Thanks for letting me know, I’ve updated the article accordingly.