本帖最后由 xczxczxcz 于 2018-11-3 23:14 编辑
- $ext=(dir .\*.*|select -last 1).Extension
- Foreach($file in (Gc (Dir ".\*.*" -Recurse -Exclude "*.ps1"))){"$file"|Ac ".\new.$ext.txt"}
- Move-Item ".\new.$ext.txt" ".\new.$ext"
- pause
复制代码 保存为 XXX.ps1
下面这个是按后缀类型归类。- (dir .\*.* -Recurse -exclude "*.ps1").extension |sc ".\xyz"
- [System.Collections.Generic.HashSet[string]]$lines=gc ".\xyz" -ReadCount 0|Select -Unique
- sc ".\xyz1" -Value ($lines -join "`r`n");
- Foreach($ext in (gc ".\xyz1")){Foreach($file in (Gc (Dir ".\*$ext" -Recurse))){"$file"|Ac ".\Total$ext"};};
- remove-item ".\xyz*"
- pause
复制代码
|