Batch file 将修改txt文件中日期的批处理文件

Batch file 将修改txt文件中日期的批处理文件,batch-file,Batch File,我试图使用批处理文件修改文本文件中的一行。本例中的行是lastexportdate=2014-01-01。我正在尝试获取批处理文件以从中修改此内容 lastexportdate=2014-01-01 到 这是否可能与我的计算机的时间戳相等?不知道如何着手解决这个问题,所以如果有人能帮上忙,那就太棒了。我正在使用Windows7 文件内容如下: root.footer=</CREDITEXPORT> root.header=<CREDITEXPORT> emailaddr

我试图使用批处理文件修改文本文件中的一行。本例中的行是
lastexportdate=2014-01-01
。我正在尝试获取批处理文件以从中修改此内容

lastexportdate=2014-01-01

这是否可能与我的计算机的时间戳相等?不知道如何着手解决这个问题,所以如果有人能帮上忙,那就太棒了。我正在使用Windows7

文件内容如下:

root.footer=</CREDITEXPORT>
root.header=<CREDITEXPORT>
emailaddronsuccess=test@test.com
emailaddronerror=test@test.com
rerunexportdate=2014-09-06
errorfilelocation=C:\\ 
lastexportdate=2014-01-01
xmloutputlocation=C:\\
root.footer=
root.header=
emailaddronsuccess=test@test.com
电子邮件地址错误=test@test.com
重新发布日期=2014-09-06
errorfilelocation=C:\\
lastexportdate=2014-01-01
xmloutputlocation=C:\\
@echo off
setlocal
rem正在获取当前时间戳
设置“beginJS=mshta”javascript:var t=new Date();var dd=t.getDate();变量mm=t.getMonth()+1;var yyyy=t.getFullYear();如果(dd^>temp.file
如果“%%a”eq“lastexportdate”echo%%a=%cds%%>>temp.file
)
未测试。只需更改内容文件的位置并检查创建的temp.file是否正常。
要替换文件,请在末尾添加
移动临时文件“%content\u file%”

。刚试过这个,效果很好。我真的很感谢你的帮助。嘿,我需要做什么才能输入昨天的时间戳?这是我能做的一个简单的修改吗?
root.footer=</CREDITEXPORT>
root.header=<CREDITEXPORT>
emailaddronsuccess=test@test.com
emailaddronerror=test@test.com
rerunexportdate=2014-09-06
errorfilelocation=C:\\ 
lastexportdate=2014-01-01
xmloutputlocation=C:\\
@echo off
setlocal

rem getting current time stamp
set "beginJS=mshta "javascript:var t=new Date();var dd=t.getDate();var mm=t.getMonth()+1;var yyyy=t.getFullYear();if(dd^<10) dd='0'+dd;if(mm^<10) mm='0'+mm;close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write("
set "endJS=));""


:: FOR /F does not need pipe
for /f %%N in (
  '%beginJS% yyyy+'-'+mm+'-'+dd %endJS%'
) do set cds=%%N
echo cds=%cds%


rem processing the file
rem set the location of the file
set "content_file=c:\some.file"
break>temp.file
for /f "usebackq tokens=1* delims==" %%a in ("%content_file%") do (

  if "%%a" NEQ "lastexportdate" echo %%a=%%b>>temp.file
  if "%%a" EQU "lastexportdate" echo %%a=%cds%>>temp.file
)