Rename a bunch of files/Directories

This has been quite useful to me as well Files:get-childitem “*.xml” | foreach { rename-item $_ $_.name.Replace(“NES-“, “NES-X”) }Replace Directories:Get-ChildItem -path PROD -Directory | ForEach-Object -Process {Rename-item -path $_.Name -NewName ($_.name.substring(4,8)) -Verbose }Another example:Get-ChildItem ‘C:\Temp\crs\documents’ | rename-item -newname { $_.name.substring(0,45) + ‘_Client_Report.pdf’} Here a viante to add a string to an existing file nameget-childitem “*.pdf”…

Replace a string inside a list of files

Sometimes we need to replace a character string into a flat-file.One possible method could be to use a tool, like notepad++ and open the bunch of files and use the scan replace options.But a quick way is again using PowerShell like below ls “\cb.n.lo\dfs\reg01\interfaces\T24\From\523.Asn\LU0010001\DOC\NES-TEST\*.xml” -rec | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace “/Net_Equity_Statement-“,…