In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article for everyone to show the DOS batch processing %~dp0 and other expansion variable syntax example analysis, concise and easy to understand, absolutely can make you shine, through the detailed introduction of this article I hope you can harvest.
Sometimes we see others using %~dp0
~ is the meaning of extension, equivalent to converting a relative path into an absolute path
%0 refers to the batch file itself
%1 indicates the first parameter received on the batch file command line,%2 indicates the second, and so on
%~d0 refers to the drive letter where the batch is located, where d represents drive
%~p0 refers to the directory where the batch is located, where p represents path
%~dp0 is the letter and path where the batch is located
cd %~dp0 is to enter the directory where the batch processing is located
For further explanation, please refer to the command call /?
What does %~dp0 mean in DOS batch processing?
(Note: %0 is the file name of the batch file)
And that means
Change the current directory to the directory of the batch itself
A little dizzy? Take your time. Let me give you an example.
For example, if you have a batch a.bat in the E:/jb51 folder
a.bat content is
cd /d %~dp0
here
cd /d %~dp0 means cd /d e:/jb51
%0 represents the batch itself e:/jb51/a.bat
~dp is a variable extension
d is extended to partition number e:
p is extended to path/jb51
dp is extended to partition number path e:/jb51
Below is a picture.
Extended variable syntax details:
:: Option syntax:
:: ~I -Remove any quotes ("), extend %I
:: %~fI -expands %I to a fully qualified pathname
:: %~dI -Extend %I to a single drive letter only
:: %~pI -only extend %I to a path
:: %~nI -only extend %I to a filename
:: %~xI -only extend %I to a file extension
:: %~sI -Extended path contains only short names
:: %~aI -extends %I to file attributes of file
:: %~tI -Date/time %I was extended to file
:: %~zI -Extend %I to file size
:: %~$PATH:I -Find directories listed in path environment variable and extend %I
:: To find the first fully qualified name. If the environment variable name
:: undefined, or file not found, this key combination expands to
:: Empty string
:: Modifiers can be combined to get multiple results:
:: %~dpI -extend %I to only one drive letter and path
:: %~nxI -only extend %I to a file name and extension
:: %~fsI -only expand %I to a full pathname with a short name
:: %~dp$PATH:i -Find directories listed in path environment variable and extend %I
:: To the first drive letter and path found.
:: %~ftzaI -extends %I to DIR like output lines
Here is an example:
If an install.bat file is located at D:\jeesite\bin
The document reads as follows:
@echo offecho [INFO] This is a demo.echo [INFO] %~dp0pause
Run install.bat and the command line output looks like this
[INFO] This is a demo. [INFO] D:\jeesite\bin\
Namely:
%0 represents the file itself
d stands for drive letter
P stands for path.
Extended options also include:
%~f0 -full path + filename
[INFO] D:\jeesite\bin\install.bat
%~n0 -filename (no extension)
[INFO] install
%~x0 -file extension
[INFO] .bat
%~s0 -Extended path contains only short names ("s" is Short, short)
%~a0 -extends %0 to file attributes of file ("a" is attribute)
%~t0 -Date/time %0 was extended to file ("t"time)
%~z0 -Expand %0 to file size (Size)
The above content is DOS batch processing %~dp0 and other extension variable syntax example analysis, you have learned knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.