Hi everyone,

I have a problem which needs an urgent solution!

I recently uploaded hundreds of images to the pictures section of my website with file names like this:

rihanna-battleship-movie-premiere.jpg

It was only after I uploaded hundreds of images adding the file extension ".jpg" that I realised that I should not have added this file extension to each file name as now these images are appearing on the website as rihanna-battleship-movie-premiere.jpg.jpg and are therefore not appearing on successfully on google.

Is there a way that I can remedy this problem quickly without having to replace each separate image with a replica image with the correct file name?

Many thanks.

Recommended Answers

All 6 Replies

In Windows explorer, configure the view to show extensions. Verify whether the .jpg is part of the file names. For example image.jpg.jpg. If so, you really should correct this.

If not you may be inserting .jpg additionally in your website coding.

If you have added them with the doubled extension and there really are hundreds of them, write a script to get all images in the folder and rename each one in turn (taking the file name part, ignoring the extension, and checking if it contains .jpg. If it does do a string.replace to remove it.
Be a lot faster than renaming them all by hand.

Thanks Hericles,

How would this all work? Would the same image files still show successfully on the website but would just have different file names minus the .jpg file extension once your solution is implemented?

And how easy is this to carry out? As I am a beginner

I'm not sure how the website is loading the images but as it shows the image with the incorrect name now (rather than not showing anything because the URL is incorrect) I'm guessing that as soon as everything is renamed the images will display correctly sans the repeated .jpg.
Have a look at this post: http://bytes.com/topic/c-sharp/answers/440212-renaming-files-directory
You want to do almost the same thing but instead of moving files like he is, you need to get the file part of the name of each file in the FileInfo array and check if it contains .jpg. If yes, strip it out.

Hi there thanks for this.

The web marketing company I am using say they can add some information to the robot.txt file which will instruct google to view images with this file extension .jpg.jpg as a simple jpg file.

Would this work?

Can't help you there I'm afraid, my knowledge of the robots.txt file only handles how to hide files and folders. I would have to assume they know what they are doing though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.