1 $path = ".\Pictures\Saved Pictures"
 2 
 3 $filenamelist=@()
 4 Get-ChildItem $path | ForEach-Object -Process{# 注意: { 必须紧跟着 Process
 5     if ($_ -is [System.IO.FileInfo]) #如果想要得到文件就用 System.IO.FileInfo
 6     {
 7         $filenamelist+=($_.name)
 8     }
 9 
10 }
11 #Write-Host ($filenamelist);
12 $number=1
13 foreach ($filename in $filenamelist)
14 {
15     $newName=[io.path]::combine($path,('{0:d4}' -f $number)+$filename.Substring($filename.Length-4))
16     write-host $newName
17     ren $path\\$filename $newName 
18     $number++    
19 }
20 Pause