Sort image files by metadata

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
LK51
Level 1
Level 1
Posts: 48
Joined: Tue May 09, 2017 2:03 pm

Sort image files by metadata

Post by LK51 » Mon Apr 15, 2019 10:03 am

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.

User avatar
phd21
Level 19
Level 19
Posts: 9187
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: Sort image files by metadata

Post by phd21 » Mon Apr 15, 2019 11:08 am

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....
Phd21: Mint KDE 18.3 & 19, 64-bit Awesome OS, Ancient Dell OptiPlex 780 Core2Duo E8400 3GHz,4gb Ram,256gb SDD, Video: Intel 4 Graphics, DVD Lightscribe. Why I use KDE?:https://opensource.com/life/15/4/9-reasons-to-use-kde

User avatar
xenopeek
Level 24
Level 24
Posts: 24065
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Sort image files by metadata

Post by xenopeek » Mon Apr 15, 2019 11:18 am

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
Image

LK51
Level 1
Level 1
Posts: 48
Joined: Tue May 09, 2017 2:03 pm

Re: Sort image files by metadata

Post by LK51 » Mon Apr 15, 2019 2:32 pm

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...

User avatar
phd21
Level 19
Level 19
Posts: 9187
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: Sort image files by metadata

Post by phd21 » Mon Apr 15, 2019 2:56 pm

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
Phd21: Mint KDE 18.3 & 19, 64-bit Awesome OS, Ancient Dell OptiPlex 780 Core2Duo E8400 3GHz,4gb Ram,256gb SDD, Video: Intel 4 Graphics, DVD Lightscribe. Why I use KDE?:https://opensource.com/life/15/4/9-reasons-to-use-kde

Post Reply

Return to “Software & Applications”