Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save keithoma/882dc8c14ea23ccd3eb8dd29f455625d to your computer and use it in GitHub Desktop.

Select an option

Save keithoma/882dc8c14ea23ccd3eb8dd29f455625d to your computer and use it in GitHub Desktop.
Get-ChildItem -Directory -Recurse |
Sort-Object { $_.FullName.Length } -Descending |
ForEach-Object {
$newName = $_.Name -replace ' ', '_'
if ($newName -ne $_.Name) {
Rename-Item -LiteralPath $_.FullName -NewName $newName -WhatIf
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment