我有一些數據的HTML文件,並有一條線在那裏的當前日期添加到HTML文件:如何使用批處理文件
<span style='font-family:"Arial","sans-serif"'><span style='color:gray'> January 1, 2013</span></span>
是否有使用批處理文件來替換的方式日期與當前日期?
我有一些數據的HTML文件,並有一條線在那裏的當前日期添加到HTML文件:如何使用批處理文件
<span style='font-family:"Arial","sans-serif"'><span style='color:gray'> January 1, 2013</span></span>
是否有使用批處理文件來替換的方式日期與當前日期?
另存爲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);
爲什麼從一個批處理文件?是否有一個原因,你不想使用PHP或Javascript來抓取今天的日期? http://www.php.net/manual/en/function.date.php 使用'<?php回聲日期(「Y/m/d」); ?''會爲你打印今天的日期...... – Scott
[SSI](http://www.ssi-developer.net/ssi/ssi-date.shtml)也值得一提。 –