Sorting photographs
I've got over 40 directories containing a couple of thousand individual photographs that I'd really like to sort, and I'd like to sort them by date, preferably by their creation date. But as I understand it, Linux doesn't currently have a creation date, only a modification date. Is there any way I copy them into one big directory, run a sort command, then have the photos in this directory shown visually in their correct order in a GUI, so that I can then put them back into individual directories based upon
digiKam their timestamp? I've done a bit of searching online, but I’ve found that there’s nothing immediately obvious. Any help would be gratefully appreciated. GeordieJedi From the forums Digital camera files contain data other than the actual image, called EXIF (see http://bit.ly/EXIFDefined for more detail). This can include exposure settings; lens focal length; ISO value; whether flash was used; and even GPS co-ordinates. Most importantly, EXIF data includes a timestamp. Many digital image-handling programs can work with this information. DigiKam, my personal choice, displays this information with each thumbnail, and shows more when you select an image. It also enables you to view photos by date, presenting them in virtual year and month folders and sub-folders, whatever their on-disk organisation.
If you want to re-organise thousands of files like this, you’re going to have to do some scripting and the program you need is ExifTool. This reads (and writes, but that’s not relevant here) EXIF tags. Using the following command: exiftool photo.jpg shows you all the EXIF data for a file, but we are only interested in one tag, DateTimeOriginal, which you can read with: exiftool -DateTimeOriginal photo.jpg The output from ExifTool can be customised however you want. Read the man page for details of the -p and -d options, but this will give the sort of information you need: exiftool -d '%Y %m' -p '$FileName $DateTimeOriginal' *.jpg
For each photo, it outputs three items on a line: the name of the file, the year it was taken and the month. Now you can use a short script to move all the files: