来个简单的 PS用法自查- (ls -Rec | ? { $_ -is [IO.DirectoryInfo] }).FullName | Foreach {
- $Jpg = ls $_\IMG*.jpg;
- if ($Jpg) {
- if ($Jpg[0]) { Ren $Jpg[0].FullName -NewName '机台照.jpg' -Force -ea 'SilentlyContinue' }
- if ($Jpg[-2]) { Ren $Jpg[-2].FullName -NewName '全景.jpg' -Force -ea 'SilentlyContinue' }
- if ($Jpg[-1]) { Ren $Jpg[-1].FullName -NewName '喷漆.jpg' -Force -ea 'SilentlyContinue' }
-
- if ($Jpg.Count -gt 3) {
- $n = 0;
- For ($i = 1; $i -lt $Jpg.Count - 2; $i++) {
- Ren $Jpg[$i].FullName -NewName ([String]::Concat("$n", '-', ($n + 5), 'm.jpg'));
- $n += 5;
- }
- }
- }
- }
复制代码
|