- #@&cls&powershell "type %~s0|out-string|iex"&pause&exit
- $a=gc '123.txt'
- dir '123\*.txt'|%{
- $n=$_.fullname
- while(test-path $n){
- if($n -match '.*?-(\d+)\.txt$'){
- $n=$matches[0] -replace '(\d+)(?=\.txt$)',([int]$matches[1]+1)
- }else{
- $n=$_.DirectoryName+'\'+$_.basename+'-1'+$_.extension
- }
- }
- sc $n $(gc $_.fullname|%{
- $c=$_
- $a|%{
- $d=$_ -split ','
- $d|%{
- if($c -cmatch $d[$i++]){
- if($d[$i] -ne $null){
- $e=$c -creplace "$_",$d[$i]
- }else{
- $e=$c -creplace "$_",$d[0]
- }
- }
- }
- rv i
- }
- if($e -eq $null){$c}else{$e;rv e}
- })
- }
复制代码
|