Last active
September 5, 2015 15:28
-
-
Save Dan1el42/c1a05ab044254f7898da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Param | |
| ( | |
| [Parameter(Mandatory)] | |
| [System.String] | |
| $Path, | |
| [System.String] | |
| $Filter = '*.jpg', | |
| [System.String] | |
| $NewNameFormat = 'DSC_{0:d3}.jpg' | |
| ) | |
| [IO.FileInfo[]]$Files = Get-ChildItem -Path $Path -Filter $Filter -File | | |
| Sort-Object -Property LastWriteTime | |
| for ($i = 0; $i -lt $Files.Count; $i++) | |
| { | |
| $NewName = $NewNameFormat -f ($i + 1) | |
| # Remove -WhatIf if you want files to actually be renamed | |
| Rename-Item -Path $Files[$i].FullName -NewName $NewName -WhatIf | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment