博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Filename parsing in batch file and more idioms
阅读量:4181 次
发布时间:2019-05-26

本文共 1385 字,大约阅读时间需要 4 分钟。

原文:

 

Extract the filename without the extension : ~n

for %i in (*.*) do echo %~ni

Extract the file extension without the filename : ~x

for %i in (*.*) do echo %~xi

Extract the file attribute : ~a

for %i in (*.*) do echo %~ai

Extract the file time : ~t

for %i in (*.*) do echo %~ti

Extract the drive only : ~d

for %i in (*.*) do echo %~di

Extract the path only : ~p

for %i in (*.*) do echo %~pi

Extract the complete name : ~s

for %i in (*.*) do echo %~si

Extract the file length (in bytes) : ~z

for %i in (*.*) do echo %~zi

%~$PATH:i searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string.

for %i in (java.exe) do @echo. %~$PATH:i

To remove quotes

>for %i in ("real'howto") do @echo. %i "real'howto">for %i in ("real'howto") do @echo. %~i real'howto

The path (with drive) where the script is : ~dp0

set BAT_HOME=%~dp0echo %BAT_HOME%cd %BAT_HOME%

The path (without drive) where the script is : ~p0

set BAT_HOME=%~p0echo %BAT_HOME%cd %BAT_HOME%

The drive where the script is : ~d0

set BAT_DRIVE=%~d0echo %BAT_DRIVE%

The complete script name : ~s0

set BAT_PATH=%~s0echo %BAT_PATH%

The script name only (as called with or without the extension): %0

set BAT_NAME=%0echo %BAT_NAME%

 

转载地址:http://fahai.baihongyu.com/

你可能感兴趣的文章
IOS程序开发框架
查看>>
安装jdk的步骤
查看>>
简述JAVA运算符
查看>>
简易ATM源代码及运行结果
查看>>
简述Java中的简单循环
查看>>
用JAVA实现各种乘法表
查看>>
for双重循环实现图形
查看>>
Java类和对象基础
查看>>
简述Java继承和多态
查看>>
Java中Arrays工具类的用法
查看>>
简述JAVA抽象类和接口
查看>>
JAVA常用基础类
查看>>
简述Java异常处理
查看>>
简述Java集合框架
查看>>
jQuery+ajax实现省市区(县)下拉框三级联动
查看>>
Spring中的AOP 面向切面编程
查看>>
简述Spring中的JDBC框架
查看>>
MyBatis 动态SQL
查看>>
Spring MVC体系结构和处理请求控制器
查看>>
浏览器内核的整理稿
查看>>