computer help index
 
 
Search:
"Offering free computer help, hints, and tips to the Internet populace." Now with over 3,240 tips!

Windows XP and DOS

Remembering Directories (PUSHD and POPD)

SUMMARY: Use the PUSHD and POPD commands to remember directory names in DOS with Windows XP.
 
When writing a batch file for Windows XP, have you ever had the need to switch to a different directory, perhaps to output logging or debug information, and then immediately switch back to the current directory?

Instead of storing the directory name in an environment variable, you can use the built-in PUSHD and POPD commands.

PUSHD places the current directory in an internal memory FILO (first-in, last-out) stack. It then jumps to the specified directory after the PUSHD command.

POPD pops the last directory out of the internal memory stack and goes to that directory.

Here's an example sequence of DOS commands:

C:\Downloads>pushd c:\temp

C:\temp>pushd c:\windows

C:\WINDOWS>pushd c:\

C:\>popd

C:\WINDOWS>popd

C:\TEMP>popd

C:\Downloads>

If you try to perform a POPD when no directory remains in the stack, no error is shown; you will remain in the current directory.

Note that PUSHD can also be used with network paths as well as directories. In this case, Windows will temporarily create a drive letter that points to the network directory and store that drive letter in the stack. When you perform a POPD, the temporary drive will be eliminated. Windows looks for unused drive letters Z: on down.


 
Add: Del.icio.us | Digg | Furl | My Yahoo!
 
Discuss This Tip

Print This Tip

Get E-Mail When New Tips are Online

Return to the Windows XP and DOS page.

RSS Feeds - Subscribe!
 

You want the latest tech tips and tricks in your e-mail Inbox - FREE? Type your e-mail address below and click 'Subscribe'.
 



( sample / details ) ( opt-out instructions )
 


 Free Offer! - Subscribe to the MalekTips computer help list and be one of the first to get new computer tips, articles, and download links! ( privacy policy )  ( opt-out instructions )
This page and its contents are copyright
©1997 - 2008 Envision Programming. ( copyright/disclaimer )

Home | Free Computer Help Newsletter! | Windows | Web Development | DOS and Batch Files | Removing Spyware
Digital Camera and Photography | Computer and Internet | Software | Microsoft Word
Computer Articles | About | Contribute a Tip | Link To Us! | Computer and Technology Links
RSS Feeds |  Contact Us | Advertising | Privacy Policy | Computer Help Forums