Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I used wget to download a website into a folder. When files have the same names, wget stores the new one as name.extension.#

Now I have hundreds of files like 1.jpg, 1.jpg.1, 1.jpg.2, etc.

How can I change every file with a .jpg* extension into plain .jpg?

EDIT: I used freeware NameChanger, which let me organize by EXIF data before changing the extension.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Use Name Mangler to do this. Shareware, but: Trial version: Name Mangler will work for 25 launches without limitation.

You can see the original and future file names on the left, and the configuration of Number Sequentially I used on the right. Important here is to manually define .jpg suffix, and not appending the original extension.

Screenshot of suitable configuration


The free NameChanger also can do this. (thanks slhck!)

Screenshot of suitable configuration

share|improve this answer

I'm assuming you want 1.jpg.1 to be renamed to 1-1.jpg, or you'll lose them. Quick and dirty comes to mind: just use sed to construct a shell script on the fly and have sh run it:

$ ls -1 *jpg* | sed -e 's@\(.*\)\(\.jpg\.\)\(.*\)@mv \1\2\3 \1-\3.jpg@' | grep ^mv | sh 

Strongly suggest you check the output just before the sh to make sure it's actually going to do the right thing.

share|improve this answer
    
I'm pretty sure that I'll lose –  Thalecress May 6 '12 at 2:08
    
This doesn't work with filenames that have spaces or some other special characters. –  ؘؘؘؘ May 6 '12 at 9:58

IFS=$'\n'; for f in `find . -name '*.jpg.*'`; do echo mv "$f" "`sed -E 's/(.*)\.jpg\.(.*)/\1-\2.jpg/' <<< "$f"`"; done

Another version that applies to files in all subfolders and should work with filenames that have spaces.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.