Forum Moderators: phranque

Message Too Old, No Replies

Copying and renaming one image to multiple file names

         

drummer10630

11:04 pm on Jul 19, 2010 (gmt 0)

10+ Year Member



I was recently put in charge of a website where the former webmaster put banner ads on 100's and 100's of pages within the site. There are two main folders of banner ads, totalling roughly 150 images on the server. These banner ads have been displayed on the site for years without payment. I now want to stop displaying these ads, but don't wish any red X's to be shown (so deleting the images or image folder is not an option). My idea is to make a 1x1 pixel image, and copy it (times the number of banners), and rename each one with the name of the actual banner that is being displayed now, and replace the images on the server with these 1x1 pixel images. I need two solutions to make this task easier:

1. Some way to make 150 copies of the 1x1 pixel image
2. Some way to batch rename each copy, to the correct individual file names that are on the server

Is this possible? Or do I just have to do this manually?

phranque

12:36 am on Jul 20, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], drummer10630!

it's easily done if it's some flavor of unix.
something like:

cd /banner/image/directory
for $image in *; do
cp /path/to/1x1_image.filetype $image
done

creeking

2:58 am on Jul 20, 2010 (gmt 0)

10+ Year Member



funny thought....... do a search/replace on the html image links and add

{ width="1" height="1" }


or, can you do a batch resize ?


seems like most of the work will be in replacing the linking code.

drummer10630

5:35 am on Jul 23, 2010 (gmt 0)

10+ Year Member



Well, I have just found it's going to take more than resizing. I did a test where I uploaded a few images in a 1x1 format, and now the banner is blank, but has a backround color, in the exact dimensions of the banner, and the hyperlink and alt text of the banners are still an issue. I am dreading that I may have to just delete the img code from 100's and 100's of pages manually, as the ex-webmaster even hard coded the images into many pages, and placed the image in the page's directory, rather than using the images folder...(sigh)

tangor

6:23 am on Jul 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Might there not be an easier way? Is there not a common link/src to search and replace? Nothing wrong with breaking a link to a void if the result is what is desired... just a bit of trash left in the page, as long as the image does not display and the link is busted. Quick, easy, done. Then can later clean it up if needed. Work smart, don't work hard.

rocknbil

6:17 pm on Jul 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard drummer10630, there **is** an easier way. First,

Well, I have just found it's going to take more than resizing. I did a test where I uploaded a few images in a 1x1 format, and now the banner is blank, but has a backround color


Then create that image as a colored image, not blank? Get them not displaying first, here's a thought. It's probably not the most **efficient** in terms of server load, but it would certainly be easiest.

Create **one** image. Upload it.

In your .htaccess,

RewriteRule ^images/old-ad-image.gif$ /images1x1pixel.gif [L]
RewriteRule ^images/old-ad-image2.gif$ /images1x1pixel.gif [L]

and so on, for each ad image. Pretty sure that would do it, try it on one for starters.

, in the exact dimensions of the banner, and the hyperlink and alt text of the banners are still an issue.


Yeah, if these are hard coded pages, you'll have to edit them. If it's PHP or other programming output, you could do some stuff to the output, but don't see another way other than digging in and editing.

Demaestro

7:54 pm on Jul 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



These are all fine suggestions but what you are left with in the end is a hack.

Hacks tend to make future work in areas harder, and often require additional hacks to keep it working as things change.

I suggest looking at the code that generates these banners and eliminating that. You are putting a lot of resources into customizing code so that in the end when it is done running it does nothing. So instead of making code that does nothing. Remove the code and you will have the same effect with less overhead.

drummer10630

9:14 am on Jul 27, 2010 (gmt 0)

10+ Year Member



600 down, only 400 more to go. Open index.html in Dreamweaver, delete table with banner image codes and hyperlinks, save to remote server. NEXT...