本帖最后由 terse 于 2015-12-3 22:34 编辑
回复 17# 思想之翼
WIN7 系统 的话 也可试下POWERSHELL
修正一下 写入文件- $filelist = Get-ChildItem -Path D:\数据\* -Include *.txt
- $ph1 = "D:\数据库\"
- $ph2 = "D:\搜寻\"
- foreach($file in $filelist){
- $arr = cat $file.FullName
- $name = $file.Name.split(".")[0]
- $num = 0
- $new_file = $ph2 + $name + "\"
- foreach($a in $arr)
- {
- $num++
- $array = New-Object -TypeName System.Collections.ArrayList
- $ar = $a.split(" ")
- $len = $ar.Count
- for($i=0; $i -lt $len; $i++)
- {
- $ph = $ph1 +"$($i + 1)\" + $ar[$i] + ".txt"
- get-content $ph|?{$null = $array.add($_)}
- }
- $ph = $new_file + $name + "_" + $num + ".txt"
- $str = $array| group |?{$_.Count -gt 6}| select -Exp name | Out-String
- $null = new-item -type file -path $ph -Force -Value $str
- }
- }
复制代码
|