- 帖子
- 2
- 积分
- 14
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2011-2-27
|
- Rem 取2天之前的日期,取回放入变量olddate
- echo wscript.echo dateadd("d",-2,date) >tmp.vbs
- for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo tmp.vbs') do set y=%%i
- echo %y% >tmp.txt
- for /f "delims=/ tokens=1" %%i in (tmp.txt) do set "y=%%i"
- for /f "delims=/ tokens=2" %%i in (tmp.txt) do set "m=%%i"
- for /f "delims=/ tokens=3" %%i in (tmp.txt) do set "d=%%i"
- echo %y%>> tmp.txt
- echo %m%>> tmp.txt
- echo %d%>> tmp.txt
- if %m% LSS 10 set "m=0%m%"
- if %d% LSS 10 set "d=0%d%"
- pause
- set "nowdate=%date:~0,4%%date:~5,2%%date:~8,2%"
- set "olddate=%y%%m%%d%"
- pause
- del tmp.txt /q /f
- del tmp.vbs /q /f
- echo 今天的日期:%nowdate%
- echo 2天前的日期:%olddate%
- pause
复制代码
m变量能够提取出来但是无法写入TXT文件...
还有LSS的匹配貌似无法生效,全部都加了个0上去...
求解释... |
|