Rename jpeg files with exif date using exiv2

Yeah, so I go through the trouble to write a script, to solve a problem which has already been solved. Still a fun exercise, if not exactly necessary.

Rather than using my script, most of the time I'd probably be using "exiv2", which, like "exiftags" is packaged for Debian (apt-get it) and is a great little utility that can modify exif and do other useful things, including rename files based on exif date. To rename a file using YYYY-MM-DD_HH-MM-SS.currentname format:

exiv2 -r '%Y-%m-%d_%H%M%S_:basename:' rename myfile.jpg

To rename all files in current dir:

ls "*.JPG" | while read f; do
  exiv2 -r '%Y-%m-%d_%H-%M-%S_:basename:' rename "$f"
done

To rename files in and below current dir:

find . -iname "*.JPG" | while read f; do
  exiv2 -r '%Y-%m-%d_%H-%M-%S_:basename:' rename "$f"
done

1 Comment

  • 1. Vijay replies at 23rd September 2014, 4:12 pm :

    I know it’s a few years late, but ExifTool does the same and also handles some video formats like 3gp and mp4.

    exiftool “-FileName<CreateDate" -d "%Y%m%d_%H%M%S.%%e" .

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).