Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Operating System
Help Please! Need to do a batch find and replace on a directory full of html files
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="novicew" data-source="post: 324004" data-attributes="member: 14781"><p>If you are familiar with the Terminal.App, you need just a single command for that <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /></p><p></p><p>1)Open Terminal.App (/Applications/Utilities/Terminal)</p><p></p><p>2)cd to the directory where you have all the html files (eg. <span style="color: Red">cd ~/Sites/Mywebsite/</span>)</p><p></p><p>3)type <span style="color: Red">find -type f | xargs perl -pi -e 's/<String you want to replace>/<String you want to be replaced with>/g' </span> and hit enter. (eg. <span style="color: Red">find /Users/novicew/newsite/ -type f | xargs perl -pi -e 's/blablabla/blabla/g'</span>)</p><p></p><p>You can also define the specific file type you want the system to search as follows.</p><p><span style="color: Red">find /Users/novicew/newsite/ -type f | xargs perl -pi -e 's/blablabla/blabla/g' *.html</span></p><p></p><p>Possibilities are endless, you just need to find them <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /></p></blockquote><p></p>
[QUOTE="novicew, post: 324004, member: 14781"] If you are familiar with the Terminal.App, you need just a single command for that ;) 1)Open Terminal.App (/Applications/Utilities/Terminal) 2)cd to the directory where you have all the html files (eg. [COLOR="Red"]cd ~/Sites/Mywebsite/[/COLOR]) 3)type [COLOR="Red"]find -type f | xargs perl -pi -e 's/<String you want to replace>/<String you want to be replaced with>/g' [/COLOR] and hit enter. (eg. [COLOR="Red"]find /Users/novicew/newsite/ -type f | xargs perl -pi -e 's/blablabla/blabla/g'[/COLOR]) You can also define the specific file type you want the system to search as follows. [COLOR="Red"]find /Users/novicew/newsite/ -type f | xargs perl -pi -e 's/blablabla/blabla/g' *.html[/COLOR] Possibilities are endless, you just need to find them ;) [/QUOTE]
Verification
Post reply
Forums
Apple Computing Products:
macOS - Operating System
Help Please! Need to do a batch find and replace on a directory full of html files
Top