Skip to content

Instantly share code, notes, and snippets.

@flaviotsf
Created August 9, 2012 22:00
Show Gist options
  • Select an option

  • Save flaviotsf/3308418 to your computer and use it in GitHub Desktop.

Select an option

Save flaviotsf/3308418 to your computer and use it in GitHub Desktop.
Rename Files for Web
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