Created
August 9, 2012 22:00
-
-
Save flaviotsf/3308418 to your computer and use it in GitHub Desktop.
Rename Files for Web
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
| Clear-Host | |
| cd "C:\YourFolder\" | |
| #note I am only selecting jpeg files | |
| ls *.jpg | Foreach-Object { | |
| $NewName = (($_.BaseName -replace '-', ' ') -replace '_', ' ') | |
| $NewName = (Get-Culture).TextInfo.ToTitleCase($NewName) | |
| $NewName = ($_.BaseName -replace ' ','-') + $_.Extension | |
| #this will just print the name | |
| $NewName | |
| #to rename uncomment the line below | |
| #Rename-Item -Path $_.FullName -NewName $NewName | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment