Welcome to WebmasterWorld Guest from 50.19.34.234

Forum Moderators: open

Message Too Old, No Replies

Find & Replace with different replacement text each time

I want the replacement text to be variable from a list

     

soccer_star

5:39 pm on Jan 14, 2011 (gmt 0)

10+ Year Member



Hi

I have 1,000 html pages, the title of which is a name. The title tag of these pages is <title>name</title> ready for me to insert the correct name. Eg:

alice.html <title>name</title>
bob.html <title>name</title>
john.html <title>name</title>

I want to end up with:

alice.html <title>alice</title>
bob.html <title>bob</title>
john.html <title>john</title>

I have a text file with all the names listed in alphabetical order. So my text file reads:

alice
bob
john
(etc)

So I basically need a batch program to find 'name' in the first file (alice.html) and replace 'name' with the first name in my list (alice), then find the next instance of 'name' (in bob.html) and replace it with the second name in the list (bob) and so on. I have found a program to do that for file names, but not text within a file.

Can anybody help? I am using Dreamweaver CS5 for Mac if that helps, but could use a Windows program if necessary.

Thanks.

calder12

5:10 pm on Apr 29, 2011 (gmt 0)



I've personally never heard of a program capable of doing that to be honest, it could be programmed but it would be a bit of a headache.

The reason I'm responding is basically I'm confused about this, to be honest it really seems like you're going to a lot of work to create a lot of pages that could be done in code with either asp or php.

Without knowing what you're trying to accomplish I can't be sure obviously but is there any reason your site couldn't be done dynamically rather than being hard coded html pages?

coopster

2:15 pm on May 2, 2011 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I use Eclipse, an open source IDE, and it is capable of finding and replacing using regular expressions within a file, a folder, or an entire project. A project can be a group of folders linked to folders in the file system. I would like to believe DW would have a similar feature set. If not, you should be able to use the command line to find and replace values as well. Perl is a great command line tool for getting this task accomplished.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month