Multi-file replace Query - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: Multi-file replace Query

KiwiBrian wrote:

Quoted text here. Click to load it

David's suggestions about this are right.  I couldn't live
without an Apache server on my hard drive.

To automate,
In a short perl program, using URI::URL's 'rel()' method:

use File::Find;
use URI::URL;

my $base_url = URI::URL->new(' ');
my $abs_url = URI::URL->new('');
my $rel_url = $abs_url->rel($base_url);

The above can be programmed to iterate with File::Find.
Iterate over all the urls with File::Find,
letting File::Find and a regular expression find new $abs_urls
so that you compute a new $rel_url each time it finds one.
Replace the old $abs_url with a new $rel_url each time.

Re: Multi-file replace Query wrote:

Quoted text here. Click to load it

Should have said:
Replace the old filename in the file with the string in $rel_url each time.

Re: Multi-file replace Query

On Wed, 10 Nov 2004 14:03:10 -0500, "Tina - AffordableHOST, Inc."

: >I have a need to replace every occurance of a particular graphic file which
: >occurs in many folders, at several levels, in a site that I have on my hard
: >drive.
: > I can tolerate the new file having a different name if this is necessary
: > for the process as I can do a site-wide rename of every ocurance of that
: > filename within the source files, but I don't know of any tool or
: > application that will let me replace the actual files.
: > Any help or pointers appreciated
: > Brian Tozer
: Rather that create a workaround for this problem, you might consider taking
: this opportunity to better organize your website structure.  If you have one
: graphic, being called from many different files, you should consider putting
: the graphic in ONE folder and calling to it in every instance.  This will
: make changing the graphic a little easier next time around.

Yes, Tina.   Very sensible.   :)


Site Timeline