Jan 282008

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


stem>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:\Documents and Settings>popd


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)


To naavigate to a share and assign a drive letter

C:\>pushd \\fileserver\shared-docs\


To come back and clear the share



The system cannot find the drive specified.



Incoming search terms:

  2 Responses to “PUSHD & POPD to navigate directories temporarily in DOS command line”

  1. 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,

  2. You are right! It indeed is LIFO.

    Thanks for letting me know, I’ve updated the article accordingly.

Sorry, the comment form is closed at this time.