2

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.

4 Answers 4

3

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

0
1

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.

2
  • I'm pretty sure that I'll lose
    – Thalecress
    May 6, 2012 at 2:08
  • This doesn't work with filenames that have spaces or some other special characters.
    – Lri
    May 6, 2012 at 9:58
0

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.

0

This is an easy to remember way of renaming multiple files in the Terminal:

rename 's/\.jpg.1/\.jpg/' *.jpg.1

Just put whatever extension after each /\. and make sure to specify the existing files in the second argument (*.jpg.1 in this case)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .