目的是为了结合之前的wav2mp3语句,将5分钟之前创建的wav文件转换为mp3,降低错误率。
脚本
@echo off & SETLOCAL EnableDelayedExpansion
set rq=%date:~2,2%%date:~5,2%%date:~8,2%
::批处理最高32位,精度不够,所以年份只能用简写
set sj=%time:~0,2%%time:~3,2%
set sj=%sj: =0%
::日期部分处理并对小时补零
set /a now=%rq%%sj%-5
::计算5分钟之前的日期时间
for %%i in (*.txt) do (
set b=%%~ti
set a=!b:~2,2!!b:~5,2!!b:~8,2!!b:~11,2!!b:~14,2!
echo %%i !a! 小于 %now%
if "!a!" lss "%now%" (echo yes) else (echo no)
)
通过WMIC获取标准时间
@echo off & SETLOCAL EnableDelayedExpansion
for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value') do set t=%%a
set /a now=%t:~2,10%-5
for %%i in (*.txt) do (
set b=%%~ti
set a=!b:~2,2!!b:~5,2!!b:~8,2!!b:~11,2!!b:~14,2!
echo %%i !a! 小于 %now%
if "!a!" lss "%now%" (echo yes) else (echo no)
)
修改系统默认日期格式实现
@echo off
set K=%time:~0,2%
set/a K=%K: =%*60+1%time:~3,2%-100-5,D=1%date:~8,2%-100
set/a D-=!!(%K:-=%-K),K+=!!(%K:-=%-K)*1440,H=K/60,F=K-60*H,M=1%date:~5,2%-100-!D,Y=%date:~0,4%-!M,M+=!M*12,"K=!(M-4)|!(M-6)|!(M-9)|!(M-11)","D+=!D*(!(M-2)*(28+!(Y%%4))+K*30+(!!(M-2)&!K)*31)"
set M=0%M%&set D=0%D%&set F=0%F%&set H=0%H%
echo 文件修改时间---条件时间%Y%-%M:~-2%-%D:~-2% %H:~-2%:%F:~-2%
for %%i in (*.txt) do echo %%i %%~ti
echo 满足条件的文件
for %%a in (*.txt) do if "%%~ta" lss "%Y%-%M:~-2%-%D:~-2% %H:~-2%:%F:~-2%" echo %%a超过时间
pause
::%%~tI 输出时间为2011-01-12 08:05
::%date% 的格式为2011-01-12 ......
::%time% 的格式为 8:27:35.25
PS:完美看不懂!!!
代码出处http://bbs.bathome.net/redirect.php?goto=findpost&ptid=10737&pid=68535&fromuid=54449
通过第三方处理
for /f "delims=" %%a in ('*.txt /nh /t::~-5m') do echo %%a yes
源程序http://www.bathome.net/thread-30609-1-1.html
备份下载
- 百度网盘
- 提取码:
t2rj