- //&cls&cscript -nologo -e:jscript "%~f0" "1.txt"&pause&exit
- function Add(i){return i<10?"0"+i:i;}
- var now = new Date();
- var dt = now.getFullYear()+Add((now.getMonth()+1))+
- Add(now.getDate())+
- Add(now.getHours())+
- Add(now.getMinutes());
- var fso = new ActiveXObject('Scripting.Filesystemobject');
- var file = WSH.Arguments(0);
- var f = fso.OpenTextFile(file, 1);
- var txt = f.ReadAll()+'\r\n';
- var txt = /time=[^\r\n]+\s*$/.test(txt)?txt.replace(/(time=)[^\r\n]+\s*$/, '$1'+dt+'\r\n'):txt.replace(/[\r\n]*$/, '\r\n')+'time='+dt+'\r\n';
- f.Close();
- var f = fso.OpenTextFile(file, 2);
- f.Write(txt);
- f.Close();
- WSH.echo('Done');
复制代码
|