Extensions to%0 in Windows cmd

Source: Internet
Author: User
Tags time and date

Often see%~dp0 in batches, it seems difficult to understand.

In fact, it is%0, then use ~ to place between% and 0, add some definition fields to expand.

Echo%0
Echo%~0

This is made into a bat file that executes

E:\temp>echo "E:\temp\shenxu.bat"
"E:\temp\shenxu.bat"

E:\temp>echo E:\temp\shenxu.bat
E:\temp\shenxu.bat


%~0 is to remove the double quote "

%~F0 displaying the full catalog file

E:\temp\shenxu.bat

%~D0 Display Drive number

E:

%~P0 Display Path

\temp\

%~n0 display file name, not including extension

Shenxu

%~x0 Display Extension

Bat

%~S0 display shortened name, when the file name 8 bit, no change, more than 8 digits will display the top 6, and then add ~ and 1 and extension, and finally all of you into uppercase.

Shen12~1.bat

%~A0 Display properties, which are generally--a----
%~T0 Displays the time and date of the file
Echo 2015/08/11 15:49
%~z0 Display the file size

Then, they can be used in combination.

%~dp0 Show driver number good path

%~nx0 display file name and extension, in fact, full name

Sometimes see the%~DP1, actually is the expansion of%1, and so on the line.

This article from "Genius without that 1% is absolutely impossible" blog, please be sure to keep this source http://xushen.blog.51cto.com/1673219/1683641

Extensions to%0 in Windows cmd

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.