本帖最后由 WHY 于 2016-9-7 19:20 编辑
test.ps1- function EnumerateFile($Path){
- $d = ($Path + '\').SubString(0, 2);
- $p = ($Path + '\').SubString(2) -replace '\\', '$&$&';
- $n = 0;
- $file = gwmi CIM_DataFile -Filter ("Drive='" + $d + "' and Path='" + $p + "' and Extension='jpg'");
- $file | sort LastModified -Desc | select -First 5 | %{
- if($n -eq 4){
- $n += 11
- }else{
- $n += 1
- }
- $_.Rename($Path + '\' + $n + '.jpg')
- } | Out-Null
- dir -LiteralPath $Path -Include * | ?{$_ -is [IO.DirectoryInfo]} | %{EnumerateFile $_.FullName}
- }
-
- EnumerateFile 'D:\Test'
复制代码
|