
I'm looking for a way to easily do search-and-replace for huge text blocks like in the image above... across hundreds of files.
All text editors I have can only do simple 1-line search-and-replace.
Oh I love making abominations of bash, sed, awk, etc. Just hope DoomGuy doesn't try to kill themdpJudas wrote:than use a shell script with unholy combination of grep, awk, bash, etc.
Code: Select all
string oldText = @"
// Copyright 2021 Nash Muhandes
// Blah blah blah
";
string newText = @"
// Copyright 2022 The Easter Bunny
// More blah!
";
void scanFolder(string path)
{
foreach (string filename in Directory.GetFiles(path))
{
string text = File.ReadAllText(filename);
text = text.Replace(oldText, newText);
File.WriteAllText(filename, text, new System.Text.UTF8Encoding(false));
}
foreach (string folder in Directory.GetDirectories(path))
{
scanFolder(folder);
}
}
scanFolder("C:\\Development\\NashStuff");
It doesn't support multi-line replacing AFAIK, but it is indeed capable of looking for matched cases and replace themTormentor667 wrote:I am pretty sure that Notepad++ is capable of doing that.