The
Public
Library
of Chez Luc
Call Number
344.23. LC-1

Title
Find and replace within a folder set

Author
Luke Carter

Category
Personal

Type
Productivity

Tags
Terminal, Text Expansion

About
Sometimes I need to do a find and replace for an entire set of files, but the desired files are in different places within the structure. To do this previously, I would use EasyFind and search the parent folder for the desired string using 'Search Contents', open each file, and then use a keyboard shortcut to do the same find and replace within all of the open files (in Atom). TextWrangler has a multi-file find and replace function, but I don't really like the UI of TextWrangler.

This method has the same effect and is pretty quick - and powerful. The only way I am able to remember it is by using my text expansion shortcuts in Typinator.

foldercommand
find . -maxdepth {{folder depth}} -type d -print \( ! -name . \)-exec bash -c "cd '{}' && {command to repeat goes here}" \;

and fstring
perl -pi -w -e 's/find value/replace value/g;' *.*

Here is the combonation of the two:
find . -maxdepth {{folder depth}} -type d -print \( ! -name . \)-exec bash -c "cd '{}' && perl -pi -w -e 's/find value/replace value/g;' *.*" \;