Skip to content

Instantly share code, notes, and snippets.

@alane019
Forked from ethangardner/bulk-rename.ps1
Created October 12, 2019 17:10
Show Gist options
  • Save alane019/7a3c6c78786c5a9fe958d27283faae7b to your computer and use it in GitHub Desktop.
Save alane019/7a3c6c78786c5a9fe958d27283faae7b to your computer and use it in GitHub Desktop.
Powershell script to bulk replace spaces with underscores in a directory of files
Dir | Rename-Item –NewName { $_.name –replace ,_ }
@alane019
Copy link
Author

NOTE: Replace one character with another (e.g., spaces with underscores), for a directory of folders, use the following snippet

Get-ChildItem -Directory | Rename-Item –NewName { $_.name –replace “ “,”_” }

Usage: First navigate to this directory in powershell terminal. Run as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment