Push a directory
pd.cmd
 
Many people don't know that the Windows command language contains a push-directory command, pushd and its corresponding pop-directory command, popd.
 
At any given time there is a current disk and directory associated with a command window. Any file operations that you specify, if the disk and directory are not specified, affect files in the current directory.
 
The system can keep a stack of current disk-directory pairs. When you issue the pushd command (borrowed from Unix) you change the current disk and directory to the one you specify but the previous disk and directory are remembered. Issuing the popd command will revert to that previous disk and directory.
 
pd.cmd is an enhancement to the pushd command. I use it all the time when I'm working in windows. It does not do much beyond the built-in pushd command but what it does do is very helpful.
 
The main enhancement it brings to push-directory is that it changes the window title to be the current disk and directory. That way, if you have several command windows open you can easily tell which one is which even if they are minimized.
 
The command procedure includes "help text" which you can display as follows:
 
C:\Users\David> pd -h
 
pd is a front end for the cd command that
replaces ⁄ with \ in directory names
Usage: pd [-mk] [-s] [-] [-h] [directory]
       -mk dir keyword will generate pd%keyword%.cmd to push directory dir
       -f will display the pd*.cmd files created by "pd -mk"
       -l display the directory stack
       -s or -swap will swap the top two stacked directories
       - is ignored, allowing -mk, etc. to be specified as directory names
       -h, -help, or --help will display this information
 
pd also changes the window title to be the current directory
Without any arguments, pd will display the directory stack (like -l
 
Notes: Type pushd ⁄? for help with the pushd command
pd.cmd: $Revision: 1.1 $ $Date: 2011⁄03⁄06 00:30:25 $
 
The -mk option needs a little clarification.
 
I find myself often changing my current directory to the same place. Rather than type in the directory name each time, the -mk option generates a command procedure which calls pd.cmd to change to the specified directory. The various pieces of information -mk needs to generate this new command procedure can be specified on the pd command line, but if they are not the procedure will prompt for them.
 
pd.cmd must be placed somewhere on your PATH variable. The command procedures that -mk generates will be placed in the same directory. In my case I have a directory
C:⁄Users⁄David⁄Livemesh⁄bin on my PATH where I keep all the command procedures and programs that I write.
 
The easiest way to understand -mk is by example.
 
In this example I want to create a command procedure called pdbin which will take me to the C:⁄Users⁄David⁄Livemesh⁄bin directory.
 
 
Note that pd.cmd prompts for the required information and prints the command procedure that it constructs.
 
In this example I have executed the pdbin command after it is built and also the complementary pop.cmd command procedure which is documented here.
Previous  |  Next ]     [ Up  |  First  |  Last ]     (Article 33 of 485)
 
Comments, flames, broken links?
Please send email to maintainer@intricate-simplicity.com