Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've got some photos with quite random names, but the dates (not exif, but when they were last edited) are correct. I'd like to rename them in that order, preferably so that the first photo is named "1.jpg" and so on, but anything goes. Anyone knows how that is done?

share|improve this question
    
If you search for "rename" in the Ubuntu Software Center, you'll find several utilities that make it easy to bulk rename files. pyRenamer, Purrr, and GPRename are all great options. –  ændrük May 23 '11 at 16:12
    
Also KRename & GwenRename, if your desktop is KDE –  Syborgia Alphas Jul 13 '11 at 8:49

2 Answers 2

up vote 5 down vote accepted

In the directory containing the pictures, run:

mkdir renamed; num=0; for f in $(ls -t); do cp -p "$f" renamed/IMG_$(printf "%03d" $num).jpg; num=$((num+1)); done

This will copy the files to a new directory renamed, keeping timestamps untouched. The format will be IMG_###.jpg with three-digit numbers, using leading zeros. You can change the number of digits by changing the %03d part.

share|improve this answer
    
Thanks! PS: If you want the oldest photo to have the lowest number and newest to have the last, then change ls -t to ls -tr –  Umang Oct 25 '12 at 14:04

Try PyRenamer. I have just installed it and it seems very powerful. It allows you to rename your images based on their metadata.

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.