program that will do this?

Status
Not open for further replies.

mike82

New member
Mar 3, 2007
121
0
0
I created my first site back in 1999. I've re-done the site.

Back then, for all of the images on the site, I put them all in the same directory as the html files. So I have 1 big directory of html files and images, which is kind of a mess.

Is there a program out there that will go through all of my files, and rename every image reference I.E. replace "<img src="whatever.gif"> with <img src="images2/whatever.gif"> ? I also have jpg images.

Thanks.
 


If you have host is unix/linux based and you have shell access you can use sed.

sed "s/image.jpg/images\/image.jpg/g" file.html > file2.html

file.html is your file. file2.html is your updated file.

Probably not quite what you are looking for but it works. Could be worked into a shell script fairly easily to go through all you files.
 
Ya pretty much any editing/coding software will do the trick like lorna said.
Dreamweavers my software of choice but I've heard a lot of good things about EditPlus. Also Notepad2 is pretty bad ass.
 
DreamWeaver.
1) Download entire site.
2) Rebuild cache in the manage sites area.
3) Make a folder called images
4) Select all images within the site, and move to /images/
5) Allow DreamWeaver to fix links automatically at the prompt.

Done. Reupload.
 
Textpad does that fairly easily.

Step 1: highlight the code you want to replace
Step 2: Click on edit/replace icon
Step 3: you'll see your highlighted code in the original box and underneath it will be the area to put in the NEW code.
Step 4: Select REPLACE ALL

Similar steps are used in NOTEPAD. The hotkey is Control H
 
i realize i can use the find and replace tools in notepad, etc., but i am looking for something automated. something simply and easy that will go through my entire files and replace it on its own.
 
Here's a shell script. Change IMGDIR to equal your image directory. Put the script into your html files directory. Then run it.

"sh <scriptname>"

That should do it. It will move all your html files to a backup directory and make the change chatmasta suggested above. I even tested it real quick. I take no responsibility for any damage it may cause.

#!/bin/sh
IMGDIR=images2
mkdir backup
for i in *.html; do
mv $i backup
sed "s/<img src=\"/<img src=\"$IMGDIR\//g" backup/$i > $i
done
 
Status
Not open for further replies.