楼主如是,就请cmd同门js@cscript出场相助吧,其胃口要比8K大多了,所要的三项数据正好联排,用js可直接定点剥离...
- @set @v=1 /*
- @echo off
- ::输入文件须为ansi(简中编码)
- set "jsonF=test.txt"
- (cscript.exe -e:jscript "%~f0" "%jsonF%")
- pause&exit/b
- */
- var v=WSH.arguments;
- if (v.length==0) WSH.quit();
- var fso=new ActiveXObject('scripting.filesystemobject');
- var fr=fso.opentextfile(v(0)), all=fr.readall(); fr.close();
- var line,nb,ne,line;
- for (nb=all.indexOf('\"fileId\":');
- nb>0;
- nb=all.indexOf('\"fileId\":',ne)) {
- ne=all.indexOf('\"fileType\":',nb);
- if (ne==-1) break; //遭遇残缺数据则退出
- line=all.slice(nb,ne-1);
- WSH.echo(line);
- }
- WSH.quit();
复制代码
关于utf-8文件转为简中(gb2312)编码可以试试如下的PS代码》将指定目录中的全部utf-8文件转为gb213...
- @echo off
- set "u8D=" &set/p "u8D=拖入一个仅含UTF8编码文件的目录: "
- if not defined u8D exit
- cd /d %u8D% 2>nul
- echo,转换开始...
- powershell -nop -c "$dir=dir *.*;foreach($_ in $dir){$txtLines=[System.IO.File]::ReadLines($_.FullName,[text.encoding]::UTF8);[System.IO.File]::WriteAllLines($_.FullName+'.ansi',$txtLines,[text.encoding]::Default)}"
- echo,请到 %u8D% 查看转换结果
- pause&exit/b
复制代码
|