Forum Moderators: phranque

Message Too Old, No Replies

Search & Replace software

can I import long lists of targets and replacements?

         

royalelephant

4:37 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



I have a long list of different filenames that i need to search and replace throughout many, many web files. They are text on the html pages in the form of <a href="oldfilename61.htm">target file</a>.

I want to replace them with <a href="newfilename61.htm">target file</a>

I'd like to do the operation in one shot. Is there a search and replace piece of software that will let me import a list of search targets with a complimentary list of replacements, so that the many different filenames that need to be changed will be replaced throughout all the files selected for the operation?

MM

valder

4:54 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



If you're using *nix, it should be as easy as
find ./ -type f -exec sed -i 's/search string/replacement string/g' {} \;

Be aware of that this will unfortunately update the "last edited" date of all files in the current catalog and following subcatalogs, whether they contain they string or not. I'm not sure how to avoid that.

trillianjedi

4:55 pm on Jan 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<snip> (Valder has a more elegant solution ;-))

royalelephant

5:44 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



I'm not using *nix. These are files on my home XP PC that I will later upload. I was looking for some sort of program like Xreplace32, etc.

txbakers

6:25 pm on Jan 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With Textpad (http://www.textpad.com)

You can do search/replace across multiple files easily.

I have a particular website that I install at various client sites, and always need to adjust some of the preloaded parameters in input boxes.

With Textpad, I just open up all 300 files, select Search/Replace, type in my texts, click "Replace All" and POOF! all 300 pages updated at once. Then I save all, then close all, and I'm done in under a minute.

I like that little program.

royalelephant

6:51 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



What I have in mind is doing an operation like this

SEARCH/FIND (any occurences)...
oldfilename61.htm
oldfilename64.htm
oldfilename66.htm
oldfilename69.htm
oldfilename60.htm
oldfilename30.htm
oldfilename101.htm
oldfilename109b.htm

REPLACE...
newfilename61.htm
newfilename64.htm
newfilename66.htm
newfilename69.htm
newfilename60.htm
newfilename30.htm
newfilename101.htm
newfilename109b.htm

over many, many dir's and files, where each of the above oldfile names would not necessarily be found in every html file, nor would they be found in the order shown above... sort of "any instance of oldfilename10.htm should be replaced by newfilename10.htm" no matter what precedes or succedes it.

[edited by: royalelephant at 7:08 pm (utc) on Jan. 24, 2005]

valder

6:59 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



It's text inside files you want to replace, right, and not filenames?

If it is text, I would think one of the above solutions would do well..?