Created
February 8, 2019 19:59
-
-
Save timiles/661b4e74e4f0d3ad80ce5d29cd23b6e7 to your computer and use it in GitHub Desktop.
PowerShell script to rename files ordered by last modified date
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
$files = Get-ChildItem | Sort-Object LastWriteTime | |
For ($i=0; $i -lt $files.Length; $i++) { | |
$from = $files[$i].Name | |
$to = "$($i.ToString('000')) $from" | |
Write-Host "Renaming `"$from`" to `"$to`"" | |
Rename-Item $from $to | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment