I have around 3000 jpeg photos all with names like "DSC_0596". The metadata has the date the photo was created, which would be much more useful. Is there a way to extract the date from the metadata and add it to the photo name?


ExifTool is pretty much the Swiss army chainsaw for doing these kinds of things. It has a steep learning curve, but once you're over it, the kind of renaming you're after is a snap:

exiftool -d '%Y%m%d-%H%M%%-03.c.%%e' '-filename<CreateDate' .

The -d switch tells ExifTool to format dates according to the next argument's pattern. The pattern contains date format codes that fill in various bits and pieces from the date. This would rename a file taken today at 17:34 to 20181226-1734-000.nef. The three zeros after the time are a copy number put there by %%-03.c in the date format. I'll explain why that's important in a minute.

The next argument tells ExifTool to change the filename to whatever is in the CreateDate field in the EXIF using the date format specified earlier.

Finally, the . is the path of the directory where you want to operate. You can also specify individual images if you want.

About the copy number: This is an important thing to put in your filenames because many cameras don't provide fractional seconds in their timestamps. If you had multiple files created during the same second, each successive rename would overwrite the last file and all you'd get is the last one. When picking a name, ExifTool will keep incrementing the copy number until it finds a filename that doesn't exist and rename the file to that. Note that this does not weed out duplicates. If you use this method to copy images from a card into some other directory and then run it again on the same set of images, you will end up with identical files numbered 000 and 001.

  • Is it possible to add the copy number only when necessary? I would like to have most of the files named like 20181226-1734.nef and have the number suffix only when it was required because of the collission with other file. – fracz Sep 9 at 16:50
  • @fracz EXIFTool has some ways to do things conditionally; check the docs. – Blrfl Sep 9 at 18:22

For simple things where the flexibility, power, and complication of ExifTool aren't necessary, I like to use the tool jhead. It's a command-line tool available for Linux, Mac, and Windows.


will automatically rename all files ending in .jpg in the current directory to a format like 20181226-111141.jpg. You can use %f to also include the original filename (without extension). So, for example:

jhead -n%Y%m%d-%f *.jpg

... which gives the date (and not the time) and the original filename, like 20181226-DSC_0596.jpg.

Note that there is logic to attempt to not rename files which already are mostly digits, which keeps the command from accidentally acting twice. Use -nf instead of just -n to override this. There is also logic to automatically add an incrementing trailing digit if the target filename already exists.

Also, I usually add -autorot and -ft to the command line, to match image orientation to the camera's rotation sensor and to make the file time match the exif time.

  • 1
    The problem with jhead is it requires libjpeg-turbo-progs, so it will conflict with packages that require libjpeg-progs. – xiota Dec 26 '18 at 18:38
  • @xiota That sounds like a distro-specific packaging problem. If I recall correctly, in Fedora we just replaced libjpeg across the board. – mattdm Dec 26 '18 at 21:31
  • I upvoted your answer b/c it's a good solution if it works. Just wanted to note that there might be issues installing it. – xiota Dec 26 '18 at 23:38
  • @xiota What operating system is this a problem on? – mattdm Dec 27 '18 at 10:28

Thanks all but I ended up using AmoK EXIF Sorter, a free app that does it all simply, quickly and effectively.

  • Hi Simon, welcome to Photo.SE. I'm glad you found a solution that works for you. If you don't mind, please mark your answer as the accepted answer (it's perfectly OK to ask and answer your own question). Thanks, and happy shooting! =) – scottbb Dec 27 '18 at 20:54

I use the following script, placed in ~/.local/share/nautilus/scripts (this should work for any Linux distro using Nautilus as a file manager):


exiftool -fileOrder DateTimeOriginal -recurse -extension jpg -ignoreMinorErrors '-FileName<CreateDate' -d %Y-%m-%d%%-.3nc.%%e "$@"

Doing it this way means I can select one or more files/directories and recursively rename all JPEG images in them from my mouse's right-click menu, which is pretty handy. It also ignores any files that are not JPEGs so I do not need to worry about what is in subdirectories.

Selected files are renamed in the following pattern YYYYMMDD-001.jpg. Numbering begins at 001 and continues to 999, so if you shoot 1000 or more images in one day you must modify the script (change 3nc to 4nc, the numeric value = how many digits to use).

Using the -fileOrder DateTimeOriginal argument makes sure that images are processed in order, and numbering strictly follows that order, otherwise shots takes in quick succession are not guaranteed to be renumbered in exact order they were taken.

Your Answer

