[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <# :
  2. cls
  3. @echo off
  4. cd /d "%~dp0"
  5. powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%~dp0'"
  6. pause
  7. exit
  8. #>
  9. $path=$args[0];
  10. $outfile=$path+'#result.csv';
  11. $enc=[Text.Encoding]::UTF8;
  12. $fs=New-Object System.IO.FileStream($outfile, [System.IO.FileMode]::Create);
  13. $sw=New-Object System.IO.StreamWriter($fs, $enc);
  14. $files=@(dir -liter $path -recurse|?{('.xml' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  15. for($i=0;$i -lt $files.length;$i++){
  16.     write-host $files[$i].FullName;
  17.     $text=[IO.File]::ReadAllText($files[$i].FullName, $enc);
  18.     $m1=[regex]::matches($text, '<char xml:id="[^"]*?">([\s\S]+?)</char>');
  19.     if($m1.count -ge 1){
  20.         foreach($k in $m1){
  21.             $arr=@('','','','','');
  22.             $a=[regex]::match($k.groups[1].value,'[^>]+(?=</charName>)');
  23.             if($a.success){$arr[0]=$a.groups[0].value;};
  24.             $b=[regex]::match($k.groups[1].value,'composition</localName>\s*?<value>([\s\S]+?)</value>');
  25.             if($b.success){$arr[1]='"'+$b.groups[1].value+'"';};
  26.             $c=[regex]::match($k.groups[1].value,'normalized form</localName>\s*?<value>([\s\S]+?)</value>');
  27.             if($c.success){$arr[2]='"'+$c.groups[1].value+'"';};
  28.             $d=[regex]::match($k.groups[1].value,'<mapping type="[^"]*?unicode">([\s\S]+?)</mapping>');
  29.             if($d.success){$arr[3]=$d.groups[1].value;};
  30.             $e=[regex]::match($k.groups[1].value,'type="PUA">([\s\S]+?)</mapping>');
  31.             if($e.success){$arr[4]=$e.groups[1].value;};
  32.             $line=$arr -join ',';
  33.             $sw.WriteLine($line);
  34.             $sw.Flush();
  35.         };
  36.     };
  37. };
  38. $sw.Close();
  39. $fs.Close();
复制代码
1

评分人数

提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表