locked
Automating replacing words with a hyperlink RRS feed

  • General discussion

  • I figured out the best way to do this, so I thought I would share. With some tweaking, you can apply this to other purposes.

    Let me explain what I was trying to do first. I have a folder with 650 profile HTM files. They are blues artists and each profile was saved in this format:  FIRST LAST.HM with F&A being first and last name. Or, a group was just saved with the group name. Now when I started working on this, I could not link to a file that did not exist, so I decided not to do any linking until I got a lot of profiles created. Now is that time. So, I have all these files with a name, like MUDDY WATERS in it. I want to create a hyperlink on all of them back to the MUDDY WATERS.HTM file. So, first thing I want to do is to make sure that I get the link correct. So, I open a file with MUDDY WATERS in it or just add one to a file. Then create a link back to the correct file. Then I look at the source code, copy it to the buffer. (This is every between and including the <A tag. This will put in the percent 20 for the space in the name also. I then goto the folder and select all of the files. In my case, I unhighlight the MUDDY file, so it don't link to itself.

    I then hit control F and type in what I want to search for. Which is muddy waters. I make sure that ALL SELECTED files is selected and also check FIND IN SOURCE CODE. At this point, I click on REPLACE and paste in the hyperlink and then hit the SAVE button and save the search for use later on. Go back to find and let it search and locate them all. I select all of them. It shows you the code, so you unclick any that already have the hyperlink code. It is easy to see which ones they are. 

    Now comes the trick. Right click on one of the files and select SELECT RESULTING FILES IN FOLDER LIST. That is the key. Then click on REPLACE and let it do it's magic. 

    I do advise that you back up all your files before you do it. After a few, you will get the hang of it and not have to back them up. It works flawlessly so far, and it may not be automated, but it is semi-automated and can save  you a LOT of time.

    Hope this helps someone.

    Friday, October 22, 2010 8:40 PM

All replies

  • One caveat: Never use spaces in file or folder or page names on the Web (that's the %20 you spoke of). Some servers don't deal with them properly and the links can break (Even though it may be fine on your hosting server, the servers that your pages pass through on the way to a visitor's computer may break the link.)

    Use hypen, underscore, CamelCase (medial caps), etc. to distinguish words.

    As you discovered, EW's search & replace is very flexible, so you can use it to go back and correct all of the %20 in your links (and the space problem in the file names).


    Silence is Golden. Duct tape is Silver.
    Saturday, October 23, 2010 3:29 PM