homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
Forum Library, Charter, Moderator: open

WYSIWYG and Text Code Editors Forum

This 66 message thread spans 3 pages: 66 ( [1] 2 3 > >     
How to edit a bunch of static HTML files at once?

 1:21 am on Oct 20, 2008 (gmt 0)

I have an older site that is just about 100 static html pages. Instead of hand editing 100 files, what I'd like to do is make the same edits to all of them, all at once.

I use Notepad++, which kind of does this with the "Find" and "Replace All" functions, but this only works with a small number of characters. I want to basically replace a block of code with another block of code... or just add a block of code to a specific spot without replacing anything.

Does anyone know if there is any way to do this or any program that will give me this capability?

Thanks in advance for any help.



 2:57 am on Oct 20, 2008 (gmt 0)

UltraEdit, FrontPage, and Expression Web all seem to have this ability and have worked for me. I didn't know that Notepad++ was so limited.


 6:51 am on Oct 20, 2008 (gmt 0)

Search and replace 98.

It's a small program to replace blocks of code (breaks included) in the files of a directory and its subdirectories.


 5:07 pm on Oct 20, 2008 (gmt 0)

Awesome, thanks guys!


 6:10 pm on Oct 22, 2008 (gmt 0)

PSPad has a plugin for multi line find and replace.



 4:42 am on Nov 16, 2008 (gmt 0)

cat 'file' ¦ sed "s/from/to/g" > newfile

 4:34 pm on Nov 17, 2008 (gmt 0)

just chmod all files to 777.
create phpFix.php file

//use scandir to get all files, PHP 5+
foreach(scandir($mydiroffiles) as $value){
//dont look at .. and . in directory, linux and windows
if($value !== "." && $value !== ".."){
//create handle for opening file for writing
$handle = fopen($value,"w");
//get content of file into string
$fileContent = fread($handle,filesize($value));
//replace using regular expression
$fileContent = preg_replace($regex,$replacewith,$fileContent);
//write new contents to file
//close handle
//cycle back through for each file

totally untested, but you should get the idea. Make sure you get the regular expression right, otherwise you may cause some problems for yourself. A backup would be a great idea.

good luck


 6:30 am on Dec 17, 2008 (gmt 0)

if you are using Dreamweaver then you can easily replace multiple line code for every page.. just search and replace.....


 1:42 am on Dec 25, 2008 (gmt 0)

try 'Multiple File Search & Replace' - can do alot of pages at once - it will do exactly what you asking - windows friendly.


 1:58 am on Dec 25, 2008 (gmt 0)

Much easier to use SSI, if it's stuff you know in advance that you'll be changing; such as navigation, advertisement code ...

You can do that in notepad without any extra programming required.


 3:17 am on Dec 25, 2008 (gmt 0)

FrontPage (and almost certainly Expression Web) has a good regex search and replace.

Another, nonobvious, candidate is Microsoft Visual C++ Express (free). It's a programming environment, but its search and replace (including regex and multi-file searching) is very good.

[edited by: SteveWh at 3:18 am (utc) on Dec. 25, 2008]


 4:03 pm on Dec 25, 2008 (gmt 0)

See also EditPlus3, TextEdit3, and others.

CWI Tech Guy

 9:56 am on Jan 7, 2009 (gmt 0)

This is a good thread, i've come across similar problems in the past that were resolved with a perl script of unknown origin. I'll definitely bookmark this one.


 3:01 pm on Jan 7, 2009 (gmt 0)

Ok...I have been using dreamweaver for awhile, but it always drove me nuts that it wasnt well suited for backend programing.

In my search of PHP IDE, I have come across Eclipse for PHP. This has a file find and replace, by exact phrase or regex. In addition you can choose what folders for it to search.

In addition, it is simply the best editor/programming tool I have used thus far. Did I mention it is FREE!

comes with code hints, SVN, pluggin for any programming language. The best search function. I have been only using if for about a month now. Just been unwilling to pay zen, phpIDE, etc...

I recommend everyone try it. Not a WYSIWYG though.


 3:09 pm on Jan 7, 2009 (gmt 0)

I use Eclipse exclusively and the latest release (last fall) updated the regular expression search/replace feature and is even better than earlier releases. It's like having the power of unix command line search/replace utilities inside of your project manager.


 10:04 pm on Jan 10, 2009 (gmt 0)

Pica or Arachnophilia, IMHO.


 9:49 pm on Mar 3, 2009 (gmt 0)

you may have already finished this task, but if you haven't or anyone else needs to do something similar. BK Replacem is a great utility


 9:36 am on Mar 21, 2009 (gmt 0)

It's for stuff like this that I still keep a copy of Homesite installed (first it was Allaire Homesite, then Macromedia Homesite, then Adobe bough Macromedia, and it vanished). Outdated, deprecated, bought out by progressively fatter software companies until it got relegated into not-quite-abandonware (ie: you can't buy it, but lord help you if you in any way violate the copyright). So don't go searching in the darker parts of the net for it, because that would be wrong >:-}

And still, hands down, the best HTML code editing software ever.

Mass search and replace:
All open files (organized in tabs, years before tabs were cool).
All files in a directory.
All files in a group of directories.

For old "code junkies" who never cottoned on to WYSIWIG design tools that generate their own (bloated) code, it still reigns supreme. (IMHO)

Failing that, learn Bash Scripting [tldp.org]. Specifically how to use grep [ss64.com] to pull and swap text between files.

Teaching yourself Bash might seem excessive for one little project, but it's time well spent in the long run if you ever plan on running your own servers.


 10:03 am on Mar 21, 2009 (gmt 0)

I like Actual Search & Replace. Its name says enough about many other search and replace programs that you just can't rely on. This one hasn't failed me yet and allows you to replace entire blocks of code. You don't have to manually create lists of files it needs to search through, just feed it a directory and a list of file extensions (or *.*).


 11:55 am on Mar 21, 2009 (gmt 0)

Alias Search & Replace is also excellent. Thats what I used years ago when I did static html sites. A really useful right click utility is b4Text. Right click any folder and run a multi line search & replace. Besides the PSPad multi line search and replace option, thats pretty much what I use.


Receptional Andy

 12:07 pm on Mar 21, 2009 (gmt 0)

I second BK ReplaceEm (on Windows) - fast and straightforward to use.


 1:05 pm on Mar 21, 2009 (gmt 0)

Nothing can be done as quickly as the proposed

cat 'file' sed "s/from/to/g" > newfile

which is equivalent to

sed -i "s/from/to/g" file

and when applied to multiple files at once takes the form

find . -exec "sed -i s/from/to/g {} \;"


 1:50 pm on Mar 21, 2009 (gmt 0)

And... The rest of us use TextWrangler. Powerful and free.


 2:17 pm on Mar 21, 2009 (gmt 0)

If you create xhtml (which is essentially xml), and it is well structured (it should be - really!), then you can edit your xhtml files as if they are xml: you've far more powerful means of selecting parts of the document than even a very elaborate regexp can do.

Let's say you have a wish to add a class="green" on all <a> tags that are inside a <p> that has an attribute class="widget", but no id.

Good luck to do it if you can't parse the tree semantically.


 2:52 pm on Mar 21, 2009 (gmt 0)

EditPadPlus works great for find-replace stuff. It also has handy features like "Open Folder" and "Save All" that make it great for handling large numbers of files at once. Very fast and light too.

And yes, SSI or PHP includes are the way to go for as many page elements as possible other than the main content.

swa66, that sounds incredibly cool. Assuming well-structured xhtml, what would you use to do the kind of editing you're talking about?


 3:15 pm on Mar 21, 2009 (gmt 0)

HomeSite also has a great search-and-replace function. (I use FrontPage and Expression Web for most things, but when I want to replace a block of text on a large number of files, I drag out my ancient version of HomeSite, which came free with another application years ago. I also find it convenient for editing .htaccess and RSS files.)


 3:23 pm on Mar 21, 2009 (gmt 0)

TextPad has a muli-file search-and-replace.


 3:47 pm on Mar 21, 2009 (gmt 0)

EditPadPlus works great for find-replace stuff. It also has handy features like "Open Folder" and "Save All" that make it great for handling large numbers of files at once. Very fast and light too.

EditPad is great, I use it and like it for its speed and simplicity. Also little memory consumption. The problem is when the same code changes from page to page, ej: a little extra space, numbers, etc. Then you have to use the functions again and again to tweak it.

BBedit (Mac) has wild card features, allowing you to search and replace text even if it has some different characters, you can use # for numbers, you can use * and such.


 4:56 pm on Mar 21, 2009 (gmt 0)

this thread is great for anybody working with enterprise sites with thousands maybe millions of pages. especially if you want to add a canonical tag to 30 duplicates - yes, i know that's bad; but i have seen it; or i could see it if you want to enter a call of an abstract to dynamically populate descriptions or h1's.


 4:59 pm on Mar 21, 2009 (gmt 0)

Another vote for HomeSite. And for really large block replacement, NotePro. Incredibly fast.

This 66 message thread spans 3 pages: 66 ( [1] 2 3 > >
Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved