How Many Photos Have I Taken? (Shallow Thoughts)

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Fri, 07 Aug 2026

How Many Photos Have I Taken?

I was visiting relatives, and we were looking through some photos when someone asked me, "How many photos do you have, anyway?"

I had never thought about it. But I have a Linux laptop with all my digital photos on it, so it shouldn't be too hard to answer that at least for the digital ones. (I'm not going to go count the slides in the albums on the closet shelf.)

How Many Images Total?

First, how many images do I have stored in my Images directory?

Let's assume all photos end in .jpg or .JPG. (I prefer using lower case, but in some cases, due to foibles of various software, files get uploaded in upper case, usually due to camera cards being formatted in Microsoft's VFAT format.) This will miss a few photos that I shot in raw format without a JPG equivalent, but I think most of the time when I shoot in raw, I also make a JPG. I'll use -iname to make the filename search case insensitive.

$ find ~/Images -iname '*.jpg' | wc -l
108445

That's a lot of photos.

When?

Then he asked me how much time that spanned. My digital image archive goes back to 1998, so it spans 28 years, though some of those first few years are scans of slides.

But on how many days have I actually taken photos over that time?

It's easy to count file dates: ls -l all the files, print only the dates, sort the list and then run uniq to get rid of all the duplicates. This takes much longer than the previous command, naturally, since it's doing a lot more.

$ find ~/Images/ -type f -exec ls -l '{}' \; | awk '{ print $6, $7, $8 }' | sort | uniq | wc -l
4217

But since this is looking at file dates, it's really only the days when I've *uploaded* photos to my computer, or subsequently modified the files.

No, Really When?

On how many days did I actually shoot photos? For that, you need to look at the EXIF metadata inside each file. The easiest way to do that is with jhead:

$ jhead PXL_20260722_191107635.jpg | grep 'Date/Time'
Date/Time    : 2026:07:22 13:11:07
So jhead las-conchas-pumice/PXL_20260722_191107635.jpg | grep 'Date/Time' | awk '{ print $3 }' gets you the date.

You can use exiftool rather than jhead, but exiftool for some reason lists the photo's Date/Time twice on some files:

$ exiftool PXL_20260722_191107635.jpg | grep 'Date/Time Original'
Date/Time Original              : 2026:07:22 13:11:07
Date/Time Original              : 2026:07:22 13:11:07.635-06:00
(Exiftool also has lots more options for date. Try exiftool PXL_20260722_191107635.jpg | grep Date to see them all.)

Anyway, I decided to start with jhead. I figured the command was going to take forever, so I tested it just on this year's photo directory:

find ~/Images/2026 -iname '*.jpg' -exec jhead '{}' \; | grep 'Date/Time' | awk '{ print $3 }' | sort | uniq | wc -l
122

I've taken photos on 122 days so far this year. date +%j tells me that today is the 218th day of the year, so I take photos a little more often than every other day.

For my whole collection:

$ find ~/Images -iname '*.jpg' -exec jhead '{}' \; | grep 'Date/Time' | awk '{ print $3 }' | sort | uniq | wc -l

It turned out there were so many files with EXIF errors that I decided I wanted to capture a record of that, and also record how long the command took:

$ time find ~/Images -iname '*.jpg' -exec jhead '{}' \; 2>& ~/Images/exiferrs | grep 'Date/Time' | awk '{ print $3 }' | sort | uniq | wc -l
3817
find ~/Images -iname '*.jpg' -exec jhead '{}' \; 2>&~/Images/exiferrs  118.52s user 115.55s system 88% cpu 4:25.99 total
grep 'Date/Time'  1.26s user 1.88s system 1% cpu 4:25.98 total
awk '{ print $3 }'  0.09s user 0.02s system 0% cpu 4:25.98 total
sort  0.03s user 0.01s system 0% cpu 4:26.02 total
uniq  0.01s user 0.00s system 0% cpu 4:26.02 total
wc -l  0.00s user 0.00s system 0% cpu 4:26.02 total

Four and a half minutes; that was much faster than I expected. But I was surprised that the number of days recorded in the EXIF, 3817, was less than the number of file modification dates, 4217. Is that because of all the files with bad or missing EXIF?

Trying with exiftool Instead

I haven't investigated all the errors yet. Some of them are zero length files — maybe related to a backup disaster I had many years ago, when I was relying on CDR and CD-RW for image backup, and discovered that home-written optical media are not a reliable long-term archive media. I lost a bunch of photos that way. Others are giving errors like "Illegal subdirectory link in Exif header: that seems to be a problem with jhead's EXIF reading, and exiftool can read those files. So let's change the command to use EXIFtool, using only the first 'Date/Time Original' line:

$ time find ~/Images -iname '*.jpg' -exec exiftool '{}' \; 2>& ~/Images/exiferrs2 | grep 'Date/Time Original' | head -1 | awk '{ print $3 }' | sort | uniq | wc -l

This was much slower than the jhead version: in fact, it ran for hours and got lost in an endless loop of find: ‘exiftool’ terminated by signal 13 and never actually finished.

Signal 13 is SIGPIPE and means no one is reading on the pipe any more. I still don't know why that was happening. But I decided to split it up: first generate the long list of all the dates, then sort and uniq it separately.

$ time find ~/Images -iname '*.jpg' -exec exiftool '{}' \; | grep 'Date/Time Original' | awk '{ print $4 }' >~/Images/allexifdates
find ~/Images -iname '*.jpg' -exec exiftool '{}' \;  11019.05s user 844.87s system 98% cpu 3:20:04.80 total
grep 'Date/Time Original'  1.45s user 1.52s system 0% cpu 3:20:04.80 total
awk '{ print $4 }' > /tmp/allexifdates  0.07s user 0.02s system 0% cpu 3:20:04.80 total

Turns out exiftool is much, much slower than jhead. The command that took about four and a half minutes with jhead took three and a half hours with exiftool, and it wasn't even doing the sort/uniq part.

Splitting it up and watching the output file with tail -f ~/Images/allexifdates made me notice that a lot of photos had the EXIF date 0000:00:00. So some photos aren't going to be accounted for. How many?

$ grep 0000:00:00 ~/Images/allexifdates | wc -l
1229
Admittedly not a huge number out of the 126917 total.

sort <~/Images/allexifdates | uniq | wc -l took less than a second; the total number of dates was 3728. Interesting that it was less than the 3817 total I got with exiftool; I expected it to be more, since it was counting all those files where exiftool gave errors. And I was quite surprised that both numbers were smaller than the 4217 I got just by looking at file dates; I can't explain that.

What Does it All Mean?

Anyway, apparently I took photos on somewhere above 3800-4200 days over the last 28 years.

Averages there won't tell me anything; the first few years have only a few directories, from trips where I scanned the slides, and the number gradually increases as digital cameras got better and large camera cards got cheaper.

But of course I calculated the average anyway: it's around .4, so I took photos on around 40% of all days. That's a lot higher than I expected, high enough that I'm not sure I believe it. I don't think I take photos on that large a percentage of days even now, in the days of ubiquitous cellphone cameras. Let's check last year:

$ find ~/Images/2025 -iname '*.jpg' -exec jhead '{}' \; | grep 'Date/Time' | awk '{ print $3 }' | sort | uniq | wc -l
215
$ calc 215/365
	~0.58904109589041095890

I stand corrected! These days, I take at least one photo at least every other day.

I don't know what any of this tells me ... but it was fun to figure out.

Tags: ,
[ 14:11 Aug 07, 2026    More linux/cmdline | permalink to this entry | ]

Comments via Disqus:

blog comments powered by Disqus