Welcome to WebmasterWorld Guest from 174.129.135.89

Forum Moderators: open

Message Too Old, No Replies

mass edit .html files

   
10:42 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



hi there, i want to replace all the %24 in .html files into something like &, and i have about 300 of these .html files, how do i do a mass find and replace?

both windows and unix program is fine.

i know grep can find those... that's about it. thanks mm.

4:09 am on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Frontpage has a site wide search and replace as well as dreamweaver

-Corey

4:11 am on Jul 20, 2005 (gmt 0)

10+ Year Member



There are ways to do it using VBA, visual basic in an MS Office application such as Word or Excel. You might try to Google "Batch Replace" VBA for some code.
10:07 am on Jul 20, 2005 (gmt 0)

10+ Year Member



... have you looked at the old unix 'sed', a simple but powerfull batch editor?
Or a perl one-liner?

Regards,
R.

10:34 am on Jul 20, 2005 (gmt 0)

10+ Year Member



Here is a magic perl one-liner to change and replace all text strings "%24" to "&" in all of your *.html files in your current directory:

find . -type f -name "*.html" xargs perl -pi -e 's/%24/&/g';

Just type this on your unix console shell command prompt and you are done.
The character before the xargs is a vertical bar (unix pipe), just in case this forum software should mangle this character.

Caution: as this command will overwrite your files, test it first with some test files in a test directory and check the results, before you mangle your production files.
Disclaimer: although this command worked for me very well several times, you are using it at own risk.

Hope this helps.

Regards,
R.

11:28 am on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



can you not just open all your files in a text editor and use the find/replace feature there? conText maybe? or Crimson Editor?