7

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.

How can I do that?

2
  • 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, 2011 at 16:12
  • Also KRename & GwenRename, if your desktop is KDE Jul 13, 2011 at 8:49

2 Answers 2

9

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.

2
  • 1
    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, 2012 at 14:04
  • 1
    This will mess up if filenames have spaces etc. See ParsingLs
    – Zanna
    Aug 8, 2020 at 10:09
2

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

1
  • You can use imagedate, but how do you use file metadata?
    – Redsandro
    Jun 3, 2015 at 17:21

You must log in to answer this question.

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