If command extensions are enabled, the pushd command accepts either a network path or a local drive letter and path. If you specify a network path, the pushd command temporarily assigns the highest unused drive letter starting with Z: to the specified network resource.
The command then changes the current drive and directory to the specified directory on the newly assigned drive. If you use the popd command with command extensions enabled, the popd command removes the drive-letter assignment created by pushd.
To change the current directory from the one in which the batch program was run, and then to change it back:. Skip to main content. Join , subscribers and get a daily digest of news, geek trivia, and our feature articles. By submitting your email, you agree to the Terms of Use and Privacy Policy. They can also dramatically speed up the process of navigating directories on the command line.
One of the innovations Bill Joy incorporated in his C Shell was the concept of a directory stack and the means to manipulate it: pushd and popd. Imitation being the sincerest form of flattery, the directory stack, pushd , and popd were soon incorporated into other shells like Bash and even other operating systems.
The concept of the stack is a simple one. Items are placed on the stack one at a time, with the most recently added item always occupying the top position. Actually, pushd and popd are a little more flexible than this, but this is a good model to keep in mind for now. In the following examples, note how the directory stack grows with each new pushd command. Also note that the top of the stack is to the left—this is where the new entries appear. After the first pushd command, there are two entries in the stack: the directory you left, and the one to which you moved.
This shows that, although a directory is already in the stack, it will be added again for other pushd commands. Note also that the left-most entry in the stack, which is most recently added entry, is your current directory. Some of the options you can use with pushd refer to the position of the directories in the stack.
If you want to see the numeric position of each directory, you can use the -v vertical option as shown below:. You can use the -n no rotation option to add a directory to the stack without changing the current directory. You can use numeric parameters with pushd to move to any directory in a stack, and the stack rotates when you do so.
You reference the directories in the stack by their position number. You can count from the top or bottom of the stack. We can use the following command to move that directory:. Greg Shultz is a freelance Technical Writer.
Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry. Microsoft Weekly Newsletter Be your company's Microsoft insider by reading these Windows and Office tips, tricks, and cheat sheets. Delivered Mondays and Wednesdays Sign up today.
Editor's Picks. The best programming languages to learn in Check for Log4j vulnerabilities with this simple-to-use script. TasksBoard is the kanban interface for Google Tasks you've been waiting for. Paging Zefram Cochrane: Humans have figured out how to make a warp bubble. To change the current directory from the one in which the batch program was run, and then to change it back, type:. Skip to main content. This browser is no longer supported.
Download Microsoft Edge More info. Contents Exit focus mode.
0コメント