Replace file name strings with Windows PowerShell

1

How to replace batch file name strings using Windows PowerShell ?

Ex: Replace the "" character with "_" of all files in a folder.

    
asked by anonymous 17.12.2015 / 17:29

1 answer

1

To do this you can use the following command:

Dir -R | Rename-Item -NewName { $_.name -replace " ","_" }

In this case you will recursively search for and rename files (thanks to -R ). You can also filter files that will be renamed by extension using a *.cpp

Dir -R *.cpp| Rename-Item -NewName { $_.name -replace " ","_" }
    
17.12.2015 / 17:29