Replace String within Multiple Files
Author: sam-mininbergCreated May 6, 2025Updated May 16, 2025
Hi! I started using script recently, which I've found very useful. One pattern I've found myself using is making in-place replacements across multiple files like this:
script.ListFiles("*.txt").ExecForEach("sed -i 's/tpo/typo/g' {{.}}").Wait()
I think it would be nice to have a "ReplaceInEach" function so that I could replace all sed calls with script equivalents. For example:
script.ListFiles("*.txt").ReplaceInEach("tpo", "typo")
Please let me know what you think. Thanks!
Source: bitfield/script