- #@&cls&powershell "type '%~0'|out-string|iex"&pause&exit
- cd Task
- $num = 5
- [System.Collections.ArrayList]$src = @()
- $dir = dir -filter *. | where{
- (dir $_ -name) -contains "OK" -and (dir $_ -name) -notcontains "NO"
- }
- $src += $dir | foreach{
- dir $_ -exclude OK |
- where{ (dir $_ -n) -contains "YES" }
- }
- $des += dir -filter *. | where{
- (dir $_ -name) -contains "OK" -and (dir $_ -name) -contains "NO"
- }
- $src|foreach{
- if(test-path $_\yes){
- ren $_\yes $_.parent.name
- }
- }
- $des | foreach{
- for ($i = (dir $_).count; $i -lt $num; $i++){
- if($src.count -gt 0){
- move $src[0] $_
- $src.removeat(0)
- }
- }
- }
复制代码 sorry,没注意到重命名的要求,错误提示是因为可移动对象数量和目标空位数量不对等。现在加了个if判断。(原代码是准备放到task目录下。) |