rem This batch deletes tập tin .txt trong một thư mục đã ghi rõ pushd% 1 del * .txt popd cls echo các tập tin văn bản đã xóa trong% 1 thư mục
Pushd command
Store the current directory for use by the popd command, and then change the specified directory.For a better understanding of how to use this command, see the example below.
Syntax pushd command
pushd []
Pushd commandparameter
Parameters
Describe
Specify the directory to create the current directory.This command supportsrelative paths.
/?
Show help at thecommand prompt.
Pushd command comment
Each time you use the pushd command, a single directory is stored for you to use. However, you can also store multiple directories using the pushd command multiple times. Folders are stored sequentially in a virtual stack. If you use the pushd command once, the directory you use is located at the bottom of the stack. If you use the command again, the second folder is located at the top of the first folder. The process will be repeated every time you use the pushd command.
Alternatively, you can use the popd command to change the current directory to the directory most recently stored by the pushd command. If you use the popd command, the folder at the top of the stack will be deleted from the folder. The current directory and directory will be changed to that folder. If you use the popd command again, the next folder on the stack will be deleted.Just like that.
If the command extension is enabled, the pushd command will accept either the network path or the 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 folder on the newly assigned drive. If you use the popd command with extended command utilities enabled, the popd command will delete the drive letter created by pushd .
Example pushd command
The following example shows how you can use the pushd command and the popd command in abatch program(batch program)to change the current directory from a directory on which the batch program is run.Then change back:
@echo off rem This batch deletes tập tin .txt trong một thư mục đã ghi rõ pushd% 1 del * .txt popd cls echo các tập tin văn bản đã xóa trong% 1 thư mục