SwapCD
Format: SWAPCD [
]
Template: LEVEL/N,DIR/K
Purpose: Swap the top of the directory stack
Path: Internal
Specification: SWAPCD exchanges the top or the given level of the
directory stack with either the current directory, or the
given directory should the directory be given.
The shell maintains a so-called directory stack of directories; items
can be placed on this stack by means of "PUSHCD", and retrieved by
"POPCD". SWAPCD is used to quickly switch between two directories, namely
the top entry on this directory stack and the current working directory,
or the specified directory.
SWAPCD with a given level exchanges not the top level, but the n-th level
of the directory stack with the current directory. Hence, "SwapCD 2"
exchanges the entry below the top of the directory stack with the current
directory.
Examples:
Consider the current directory is SYS: and you change into SYS:Tools with
the PUSHCD command:
1.SYS:> pushcd Tools
This will place SYS: onto the directory stack and will make SYS:Tools the
current directory.
Then, you can easely toggle between SYS: and SYS:Tools simply by SWAPCD:
1.SYS:Tools> swapcd
will re-install SYS: as current directory and will place SYS: on top of the
directory stack instead; a second SWAPCD will restore the above situation
again:
1.SYS:> swapcd
will therefore result in "SYS:Tools" as current directory again.
1.SYS:Tools>
Consider that you now push another directory onto the directory stack:
1.SYS:Tools> pushcd C:
resulting in the current directory C:
1.SYS:C>
Now the top entry of the directory stack is "SYS:Tools", below we find
"SYS:", the current directory is "SYS:C". Then
1.SYS:C> swapcd 2
exchanges the current directory "SYS:C" with level 2 of the directory stack,
which is "SYS:". Therefore, the result is
1.SYS:>
See also: PUSHCD, POPCD