How to parse parameters in a batch file

Source: Internet
Author: User
Tags microsoft website

Last week, my colleague asked me a question about writing batch files. What he wants to do is to copy files in depth, which involves parsing directories and file names. He complained for a long time and said it was not easy to use. But I found that,
MS
In fact, we have already done this job. For example:

% ~
1
You can remove the quotation marks on both sides of the parameter.

% ~
D1
You can get the drive letter.


And so on.

 

This is the parameter table about the parameters in this document.

 


Modifier



Description



% ~ 1

Expands % 1 and removes any surrounding quotation marks ("").


% ~ F1

Expands % 1 to a fully qualified path name.


% ~ D1

Expands % 1 to a drive letter.


% ~ P1

Expands % 1 to a path.


% ~ N1

Expands % 1 to a file name.


% ~ X1

Expands % 1 to a file extension.


% ~ S1

Expanded path contains short names only.


% ~ A1

Expands % 1 to file attributes.


% ~ T1

Expands % 1 to date and time of file.


% ~ Z1

Expands % 1 to size of file.

 

 

Detailed information about batch files is available on the Microsoft Website:

Http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx? MFR = true

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.