写入end.txt- //&cls&cd /d "%~dp0" & @cscript -E:javascript -Nologo "%~0" &pause&exit
- var txt = '222333.txt';
- var result = 'end.txt';
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var ifs = fso.OpenTextFile(txt,1);
- var ofs = fso.OpenTextFile(result,2,true);
- var lineNum=0,line,matchs,fmtLine;
- while(!ifs.AtEndOfLine){
- ++lineNum;
- line = ifs.ReadLine();
- //如果每行非2个 - 符号就提示
- matchs = line.match(/-/g);
- if(matchs != null && matchs.length != 2){
- fmtLine = '' + lineNum + ':\t非2个 - \t\t' + line;
- WSH.Echo(fmtLine);
- ofs.WriteLine(fmtLine);
- }
- //如果每行里,除了开头和结尾的[ ] 以外,又出现了[ 或者 ] ,就提示
- if(line.match(/(?!^)[\[\]](?!$)/) != null){
- fmtLine = '' + lineNum + ':\t出现了[,]\t\t' + line;
- WSH.Echo(fmtLine);
- ofs.WriteLine(fmtLine);
- }
- //如果每行内容中,small/81050343.jpg 中间的内容不是纯数字,就提示!
- matchs = line.match(/small\/(.*?)\.jpg/);
- if(matchs != null && matchs[1] != null)
- if(!/^\d+$/.test(matchs[1])){
- fmtLine = '' + lineNum + ':\t非纯数字\t\t' + line;
- WSH.Echo(fmtLine);
- ofs.WriteLine(fmtLine);
- }
- }
- ifs.Close();
复制代码
|