Bat-any truncation replacement character

Source: Internet
Author: User
Tags create directory

For/f ["options"] % variable in (file-set) do command [command-parameters]
For/f ["options"] % variable in ("string") do command [command-parameters]
For/f ["options"] % variable in ('command') do command [command-parameters]

Optinos
EOL = C-refers to the end of a line comment character (just one) // ignore the line whose character starts
Skip = N-indicates the number of rows ignored at the beginning of the file.
Delims = xxx-refers to the delimiter set. This character replaces the space and the Skip key // specified to be separated into delims =;:. Use ";", ":", "." To separate
Default delimiter set.
Tokens = x, y, M-n-indicates which symbol of each row is passed to each iteration.
For itself. This leads to the allocation of additional variable names. M-n
Format is a range. Use the nth symbol to specify MTH. If
The asterisks of the last character in the symbol string,
Then the extra variable will be resolved after the last symbol
Distribute and accept reserved text of rows.
Usebackq-specify that the new syntax is used in the following situations:
A string enclosed in quotation marks when executed as a command and a single
The quotation mark character is a text string command and can be used in filenameset
Use double quotation marks to expand the file name.
Column
For/F "tokens = 1-3 delims =:." % 1 in ("% time %") Do @ echo % 1-% 2-% 3
Truncates and replaces the characters returned by % time %.
For/F "tokens = 2 delims =" % 1 in ("% date %") Do @ echo % 1
Truncation of characters returned by % date %

Use % date % + % time %
Create directory
Format
2004-10-12 @ 12-11
Year-month-day @ hour-minute
For/F "tokens = 2 delims =" % 1 in ("% date %") Do @ set D = % 1
For/F "tokens = 1-3 delims =:." % 1 in ("% time %") Do @ set T = % 1-% 2
Mkdir "% d % @ % T %"
Complete bat
-----------------------------------------
@ Echo off
Setlocal
For/F "tokens = 2 delims =" % 1 in ("% date %") Do @ set D = % 1
For/F "tokens = 1-3 delims =:." % 1 in ("% time %") Do @ set T = % 1-% 2
Mkdir "% d % @ % T %"
Endlocal
----------------------------------------

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.