[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 21# newswan


    可以试试net静态类,这里只把读写改了就快了很多,如果把替换部分也改了应该还能再加速
  1. Get-ChildItem -path $sour *.txt -Recurse | foreach-object {
  2.     $_.fullname
  3.     $b=( [IO.File]::ReadAllLines($_.fullname) ) -match "\w+\s+\w+\s+[-]?\w+" -notmatch $exclude -replace "SZ","1" -replace "SH","0" -replace "\s+","|"
  4.     $a=$dest,$_.name -join '\'
  5.     [IO.File]::WriteAllLines($a,$b)
  6. }
复制代码

TOP

本帖最后由 idwma 于 2021-10-6 16:17 编辑

回复 40# newswan

去重的部分抄前辈的试试看快不快http://www.bathome.net/thread-25194-2-1.html
  1. Get-ChildItem -path $dest *.tmp | foreach-object {
  2.     $reader = New-Object -TypeName System.IO.StreamReader -ArgumentList $_.fullname
  3.     $aa=New-Object System.Collections.Generic.HashSet[string]
  4.     $_.fullname
  5.     $filename = Join-Path -path $dest -ChildPath ($_.basename + ".txt")
  6.     while ( $read = $reader.ReadLine() ) {
  7.         out-null -InputObject $aa.add($read)
  8.     }
  9.     [IO.File]::WriteAllLines($filename,$aa)
  10. }
复制代码
2

评分人数

    • PCL0769: 谢谢老师出手帮助!高技术!高人品!技术 + 1
    • newswan: 谢谢技术 + 1

TOP

回复 44# newswan


    看went的代码发现一个[void],把空输出改成这个瞬间起飞呀
  1. Get-ChildItem -path $dest *.tmp | foreach-object {
  2.     $reader = New-Object -TypeName System.IO.StreamReader -ArgumentList $_.fullname
  3.     $aa=New-Object System.Collections.Generic.HashSet[string]
  4.     $_.fullname
  5.     $filename = Join-Path -path $dest -ChildPath ($_.basename + ".txt")
  6.     while ( $read = $reader.ReadLine() ) {
  7.         [void]$aa.add($read)
  8.     }
  9.     [IO.File]::WriteAllLines($filename,$aa)
  10. }
复制代码

TOP

返回列表