Parameter modifier for the next Windows batch processing file (BAT)

Source: Internet
Author: User

Parameter extension variable (% 0 to % 9) for parameters in the next Windows batch processing file (BAT ). When the batch parameters are used in the batch file, % 0 will be replaced by the batch file name, while % 1 to % 9 will be replaced by the corresponding parameters typed in the command line. You can use the modifier in batch processing parameters. The modifier uses the current drive and directory information to extend the batch parameters to partial or complete file or directory names. To use the modifier, enter the percent sign (%) followed by the waveform symbol (~) And then enter the appropriate modifier (% ~ Modifier ). The following table lists the delimiters that can be used in extensions. Modifier description % ~ % ~ 1. Expand % 1 and delete any quotation marks ("& quot % ~ F % ~ F1 expands % 1 to a fully qualified PATH % ~ D % ~ D1 expands % 1 to drive letter % ~ P % ~ P1 expands % 1 to PATH % ~ N % ~ N1 expands % 1 to the file name % ~ X % ~ X1 extended % 1 to file extension % ~ S % ~ The s1 extension path only contains the short name % ~ A % ~ A1 expands % 1 to file properties % ~ T % ~ T1 expands % 1 to file date/time % ~ Z % ~ Z1 expands % 1 to the file size % ~ $ PATH: % ~ $ PATH: 1 search for the directories listed in the PATH environment variable and extend % 1 to the fully qualified name of the first directory found. If no stage variable name is defined or the file is not found, this modifier is expanded to an empty string. The following table lists possible combinations of delimiters and delimiters that can be used to obtain complex results: modifier description % ~ Dp0 extended % 0 to drive letter + path + file name + extension % ~ Nx1 extends % 1 to the file name and extension % ~ Dp $ PATH: 1 search for % 1 in the directory listed in the PATH environment variable and extend it to the drive letter and PATH % ~ of the first directory found ~ Dpn0 extended % 0 to drive letter + path + file name % ~ Ftza1 extends % 1 to output rows similar to dir. Note: In the preceding example, % 1 and PATH can be replaced with other batch parameters. % * The modifier is a unique identifier that represents all parameters passed in the batch file. You cannot match this Modifier with % ~ Edit character combination. % ~ The syntax must end with a valid parameter value. Batch parameters cannot be used in the same way as environment variables. You cannot search for or replace values or check substrings. However, you can assign a parameter to an environment variable and then use this environment variable.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.