我有一个带有一些数据的html文件,那里有一行:
<span style='font-family:"Arial","sans-serif"'><span style='color:gray'> January 1, 2013</span></span>
有没有办法使用批处理文件将日期替换为当前日期?
答案 0 :(得分:0)
将其另存为bat
@if (@x)==(@y) @end /***** jscript comment ******
@echo off
for /f "delims=" %%d in ('cscript //E:JScript //nologo "%~f0"') do set "c_date=%%d"
echo ^<span style='font-family:"Arial","sans-serif"'^>^<span style='color:gray'^>^ %c_date%^</span^>^</span^>
exit /b 0
***** end comment *********/
var monthNames = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
var now = new Date();
var formated= monthNames[now.getMonth()] + " " + now.getDay() +", "+ now.getFullYear();
WScript.Echo(formated);
修改强>
@if (@x)==(@y) @end /***** jscript comment ******
@echo off
for /f "delims=" %%d in ('cscript //E:JScript //nologo "%~f0"') do set "c_date=%%d"
echo ^<span style='font-family:"Arial","sans-serif"'^>^<span style='color:gray'^>^ %c_date%^</span^>^</span^>
setlocal enableDelayedExpansion
for /f "usebackq delims=" %%l in ("My_html_file") do (
setlocal disableDelayedExpansion
(echo("%%l")|findstr /i /r /c:"<span style='font-family:\"Arial\",\"sans-serif\"'><span style='color:gray'> .*</span></span>" >nul 2>&1&& echo ^<span style='font-family:"Arial","sans-serif"'^>^<span style='color:gray'^>^ %c_date%^</span^>^</span^>
(echo("%%l")|findstr /i /r /c:"<span style='font-family:\"Arial\",\"sans-serif\"'><span style='color:gray'> .*</span></span>" >nul 2>&1|| (echo(%%l)
) >> temp.html
exit /b 0
***** end comment *********/
var monthNames = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
var now = new Date();
var formated= monthNames[now.getMonth()] + " " + now.getDay() +", "+ now.getFullYear();
WScript.Echo(formated);