self-confidence,the source of all the power

导航

bat 截取字符

1.例子

echo %time:~0,-1% 

显示时间字符,从第0个到最后一个

C:\Documents and Settings>echo %time:~0,-1%
19:00:22.3

C:\Documents and Settings>echo %time%
19:00:29.49


C:\Documents and Settings>echo %date:~2,-1%
12-09-27 星期

C:\Documents and Settings>echo %date:~,3%  //第2个参数为正则表示显示的个数,为负则表示显示字符的终点下标
201

C:\Documents and Settings>echo %date:~1,3%
012

 

2.other

set str=i love you

C:\Documents and Settings>echo %str:~3%
ove you

C:\Documents and Settings>echo %str:~,-1%
i love yo

 

posted on 2012-09-27 19:07  漩涡鸣人  阅读(399)  评论(0编辑  收藏  举报