Find/Replace Script v1.0


This PowerShell script is a simple find/replace tool, much like the ones you find inside your favourite text editors. Unlike most text editors, however, this will run against all files of a certain extension within a specified folder. This enables you to edit, say for example, every CSV file in folder C:\LotsofCSVfiles.

I wrote this script as I had a large number of CSV files that I needed the same find/replace function performed on all files. Rather than opening 100+ CSV files and running a find/replace one-by-one, I could simply tell this script to search for all files in the folder and do the find/replace.

By default, the script looks for CSV files, but using the -Ext parameter, you can select a different file extension. As the standard functions work via regular expressions, I have also added a line to escape any characters to prevent failures.

Usage: .\FindReplace.ps1 -Path C:\folder\path -String “findme” -Replace “replaceme” [-Ext txt]

download-icon.273921f460a0c6119fe317a1393d1ce1 Download the Find/Replace script v1.0 here!

 


Share:
Share