- $pathSour = "."
- $fileDest = "33"
-
- if (-not ([string]::IsNullOrEmpty($args[0])))
- {
- $pathSour = $args[0]
- }
-
- remove-item $fileDest*
-
- [System.Collections.ArrayList] $al = @()
-
- $renfs = "(\w{4})(\w{1,4})?(\w{1,4})?(\w{1,5})?(.*)"
- $renfd = "`$1-`$2-`$3-`$4-`$5"
- $rem = "^ (PIPING SPEC |THERMAL INSULATION SPEC |PIPE NPD |CL LENGTH )"
- get-childitem -path $pathSour "*.prt" | foreach-object {
- write-host " "$_.basename
- $nf = $_.basename.ToUpper() -replace $renfs,$renfd -replace "-+$",""
- Get-ChildItem -path ($_.basename +".i??") -Exclude "*.idf" | ForEach-Object{
- #rename-item $_.name -NewName ($_.name+ ".dgn")
- }
- $fc = (get-content -Encoding utf8 $_.fullname) -match $rem
- $c6 = $fc -match " PIPING SPEC " -replace " PIPING SPEC (\w+)","`$1"
- $c7 = $fc -match " THERMAL INSULATION SPEC " -replace " THERMAL INSULATION SPEC (\w).*","`$1"
- if ($c7.length -eq 0) { $c7= "-" }
- $c5 = $fc -match " PIPE NPD \(MM\) " -replace ".{14}(.+)$","`$1"
- $c10 = $fc -match " CL LENGTH \(M\) "-replace ".{14}(.+)$","`$1"
- $c5 = $c5 -join "`t" -replace "\s+","`t" -split "`t" | Sort-Object { [double] $_ }
- $c10 = $c10 -join "`t" -replace "\s+","`t" -split "`t" | Sort-Object { [double] $_ }
- $al.add($nf) | out-null
- $al.add(" #6 $c6") | out-null
- $al.add(" #7 $c7") | out-null
- $al.add(" #5 " + "sum: " + (($c5 | Measure-Object -Sum).sum) + ($c5 -join "`t")) | out-null
- $al.add(" #10 " + "sum: " + (($c10 | Measure-Object -Sum).sum) + ($c10 -join "`t")) | out-null
- }
-
- $al | out-file -encoding utf8 ($fileDest + "-1.txt")
复制代码
|