Replace characters on filenames of all files in a folder (Windows)

Posted on November 14, 2017 at 11:40 am

First run PowerShell and set the current directoy to the folder where are the files:

cd C:\path\to\folder

To replace a certain character on filenames of all files in a folder, type:

Get-ChildItem -name | ForEach-Object { Move-Item $_ $_.replace(" ", "_") }

The above example will replace spaces with an underscore.

Run the script recursively in all sub-folders with -recurse param:

Get-ChildItem -recurse -name | ForEach-Object { Move-Item $_ $_.replace(" ", "_") }

Receive updates via email

Other Posts

Updated Posts