- $pathSour = ".\prt"
- $fileDest = "22"
-
- if (-not ([string]::IsNullOrEmpty($args[0])))
- {
- $pathSour = $args[0]
- }
-
- remove-item $fileDest*.*
-
- [System.Collections.ArrayList] $al = @()
-
- $rem = "^\s{3}\d{1}|^\s{2}\d{2}|^\s{11,12}\S.+"
- $renfs = "(\w{4})(\w{1,4})?(\w{1,4})?(\w{1,5})?(.*)"
- $renfd = "`$1-`$2-`$3-`$4-`$5"
- $res = "`n(.{4})(.{46})(.{13})(.{15})(.+)((?:`n\s{11,12}.+)*)"
- #$res = "`n\s{2,3}(\d{1,2})\s{4,}(\S.+?\S)\s{2,}(\d+(?:X\d+)?)\s{2,}(\S+(?:\s\S+)*)\s{2,}(\d+(?:[.]\d+)?(?:\sM)?)((?:`n\s{11,12}.+)*)"
- $red = "`t`$1`t`$2`$6`t`$3`t`$4`t`$5::"
-
- get-childitem -path $pathSour "*.prt" | foreach-object {
- write-host " "$_.basename
- $nf = $_.basename.ToUpper() -replace $renfs,$renfd -replace "-+$","";
- $a = "`n" + (((get-content -Encoding utf8 -path $_.fullname ) -match $rem) -join "`n") ;
- if ( $a.length -gt 0 )
- {
- $a = $a -replace $res,$red -replace "[ `n]+"," " -replace " *`t *","`t"
- $a = $a -replace "::$","" -replace "::","`n" -replace "(?m)\sm$","" -replace "(?m)^(?=`t)",$nf
- $al.add($a) | out-null
- }
- }
- $al | out-file -encoding utf8 ($fileDest + "-a.txt")
复制代码
|