[Batch processing] Summary of batch processing itself % 0 (including fetch path) [reprinted]

Source: Internet
Author: User

Reprinted from: http://www.hackbase.com/tech/2009-08-12/54871.html

Summary of batch processing itself % 0.
During batch processing, you often need to perform operations on yourself,
For example, extract path, file name, suffix, size, and so on ....
The % 0 extension can be easily implemented.
: Code by @ bbs.bathome.cn 2008/01/08
1. Obtain the complete batch processing path
@ Echo off
Echo % 0
Pause
2. Obtain the complete batch processing path and remove the quotation marks at the beginning and end of the batch processing.
@ Echo off
Echo % ~ 0
Pause
3. Get the batch processing file name and suffix
@ Echo off
Echo % ~ Nx0
Pause
4. Get the batch processing file name
@ Echo off
Echo % ~ N0
Pause
5. Get the suffix of the batch processing.
@ Echo off
Echo % ~ X0
Pause
6. Obtain the complete path of the batch processing, excluding the file name
@ Echo off
Echo % ~ Dp0
Pause
Or
@ Echo off
Echo % Cd %
Pause
7. Obtain the drive letter of the batch processing.
@ Echo off
Echo % ~ D0
Pause
8. Obtain the batch size.
@ Echo off
Echo % ~ Z0
Pause
9. Obtain the modification time of the batch processing.
@ Echo off
Echo % ~ T0
Pause

@ Echo off
Echo current drive letter: % ~ D0
Echo current drive letter and Path: % ~ Dp0
Echo full path of current batch processing: % ~ F0
Echo short file name format of the current drive letter and Path: % ~ Sdp0
Echo current cmd default directory: % Cd %
Pause

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.