Forum Moderators: open

Message Too Old, No Replies

DW Find & Replace

wildcards?

         

JonH

12:23 am on Jan 25, 2005 (gmt 0)

10+ Year Member




I need to change hundreds of links to files with different names while keeping the filenames as they are.

Example:

This:
<a href="filename.wav">

needs to be replaced with this:
<a href="http://www.mysite/wavs/filename.wav">

How do I exclude the "filename.wav" and do a find & replace to add the URL before the filename?

Wildcards?

tforcram

12:36 am on Jan 25, 2005 (gmt 0)

10+ Year Member



There are a couple of ways you could do this. The first is just to stick with your regular search and replace.
just put in

<a href="filename.wav">

in the 'find' box, and then put

<a href="http://www.mysite/wavs/filename.wav">

in the 'replace' box. DW will find all instances of the first and replace them with the second.

This will work great if you only have a few files to change the links over, but for hundreds of files you should probably use Regular expressions. DW help has a pretty good description of what you want to do. What you'll probably need to do is:

first make sure the 'Use Regular Expression' box is selected and make sure you have 'search' set to source code

second put your search phrase in the find box using regular expressions. In your case, that will come out probably looking something like this:

<a href="(.*)\.wav">

then you put the replacement phrase in:

<a href="http://www.mysite/wavs/$1.wav">

I haven't tested this, but I think it would work in theory. Test is out on a page and if it has the desired results then you can do a site wide search and replace. Before doing that, I recommend doind a find all first so you make sure that you aren't changing something you didn't want to.

JonH

1:09 am on Jan 25, 2005 (gmt 0)

10+ Year Member



Thanks a million. It does the job! :)
You just made the world a better place.