Page 1 of 1

Sort image files by metadata

Posted: Mon Apr 15, 2019 10:03 am
by LK51
Hope this is the right place to be asking this question…

I’m trying to organize many gigabytes of of photos for archival storage. The largest majority are “jpg’s”, though there are a fair number of “tiff’s” and “png’s” as well. What I would like to do is to use the files’ metadata so they can be sorted by original dates, as opposed to file modified dates since many of the have picked up modified dates unrelated to their original creation.

My question is- is there an app or another method available in Linux Mint to accomplish this? I’m running LM 19.1 Cinnamon and the only image related app I use is GIMP 2.10.

I appreciate any ideas you may have.

Re: Sort image files by metadata

Posted: Mon Apr 15, 2019 11:08 am
by phd21
Hi LK51,

Yes, there are apps that can sort by image metadata. Your file manager may also be able to do this just check its options.

XnViewMP · Multi-Platform Photo Viewer, Image Resizer and Batch Converter - download Linux deb file and double click it to install it.
https://www.xnview.com/en/xnviewmp/


digiKam - digiKam - in the Software Manager or Synaptic Package Manager (SPM)
https://www.digikam.org/

etc....

Re: Sort image files by metadata

Posted: Mon Apr 15, 2019 11:18 am
by xenopeek
You can do this easily by combining the find and exiv2 commands. First make sure exiv2 is installed so run this command on the terminal:
apt install exiv2

Once it's installed open a terminal on the directory where you have all the files and then you can run this command:
find . -type f -iregex '.*\.\(jpeg\|jpg\|png\|tiff\)' -exec exiv2 -T {} \;
What this command does is:
- Find all regular files in the current directory or its subdirectories that have a file extension jpeg, jpg, png or tiff
- And then calls exiv2 for each of those files to change their file modified date to the one stored in the metadata of the image

Afterwards you can sort on date in your file manager as expected!

One caveat is that some files may not have a date stored in the metadata of the file. The command will tell you each file for which that is the case.

You can also use exiv2 to rename the files. To for example prepend a timestamp to the filename so you can just sort on name. I've not done that so that would need some experimenting. See the manpage for more info on that: https://manpages.ubuntu.com/manpages/bi ... iv2.1.html

Re: Sort image files by metadata

Posted: Mon Apr 15, 2019 2:32 pm
by LK51
Wow, replies from 2 of the forums "heavy hitters"...

Thanks for your help and quick responses, I'm looking forward now to tackling this task...

Re: Sort image files by metadata

Posted: Mon Apr 15, 2019 2:56 pm
by phd21
Hi LK51,

You are welcome from all of us that replied...

...
.
Ex: Dolphin File Manager
Ex: Dolphin File Manager
.
ex: XnViewMP
ex: XnViewMP
.
ex: DigiKam
ex: DigiKam