回复 4# hello163mailcom - @echo off
- ::获取前一天日期
- >dstdate.vbs echo LastDate=date()-1
- ::设置日期格式
- >>dstdate.vbs echo FmtDate=right(year(LastDate),4) ^& right("0" ^& month(LastDate),2) ^& right("0" ^& day(LastDate),2)
- ::输出日期
- >>dstdate.vbs echo wscript.echo FmtDate
- ::批处理获取VBS输出的日期并赋值
- for /f %%a in ('cscript /nologo dstdate.vbs') do set "dstdate=%%a"
- del dstdate.vbs /f /q >nul
- copy "E:\MS SQL\Plan Logs\Plan Logs_%dstdate%*" "Plan Logs_%dstdate%_temp.txt" >nul
- ::转换编码
- iconv.exe -f utf-8 -t gbk "Plan Logs_%dstdate%_temp.txt" >> $
- for /f "delims=" %%i in ('type $') do echo %%i
- del "Plan Logs_%dstdate%_temp.txt"
- del $
- pause
复制代码 批处理跟iconv放在一起运行,需下载iconv |