When all you have is a hammer…

When I upload a photo to this blog, WordPress creates lower-resolution versions of the photo and stores them along with the original. It serves the lower-resolution photos if the browser window is too small so it can save bandwidth.

As an example, this photo:

is named IMG_0185.jpg. When I uploaded it, WordPress created files with names like IMG_0185-150x150.jpg and IMG_0185-1024x768.jpg for versions with those resolutions.

I wanted to get a list of all of the original photos in the library without the low-resolution variants and use exiftool to extract some information. It’s a fairly straightforward process.

Step 1: create a list of all the photos in the WordPress directory by using the Linux find command, like so:

find .

Step 2: use a regular expression to filter out all of the variants, all of which have a string of the form - followed by a number followed by x followed by a number followed by . and jpeg, jpg, or png. Easy enough:


find . | egrep -v '.*-[0-9]+x[0-9]+\.(jpe?g|png)'

Step 3: feed that result into exiftool, collect my information, and profit!

There was only one problem – exiftool processed every file in the directory, even the ones that weren’t in the output of Step 2.

I couldn’t figure out what was wrong – eventually, I realized that the output of find included a line with a single dot, meaning the current directory, and when exiftoolsaw it, it processed all the files in the current directory.

I spent quite a while trying to improve my regular expression to remove the line with the single dot before I realized there was a simple solution: add type -f to the find command so that it wouldn’t list directories; in particular, it wouldn’t create the line with the single dot and I wouldn’t have to filter it out so that exiftool wouldn’t get confused.

Regular expressions are a wonderful tool, but they’re not always the right tool for the job.

Overcoming the darkness

We planned to go to the JCC to work out this morning – we even got out of the house 30 minutes earlier than usual. And there wasn’t much traffic because school’s out for the summer.

We got to the corner of Los Gatos-Almaden Road and Los Gatos Boulevard – the traffic light was completely out. “That’s funny,” I thought to myself – usually the lights flash if there’s a problem. No one was coming and I was making a free right turn onto Los Gatos Boulevard, so I didn’t need to stop.

The next light was working fine, but the one after that was out. As was the light at Lark. And the ones on Lark. Everyone treated them as four-way stops – it was probably a quicker trip than usual.

Power was out at the JCC, too. During the pandemic, they had installed some fitness machines on the tennis courts and they haven’t yet removed them, so we used the stationary bicycles, which I was surprised to learn have human-powered electronics.

We took a different route home – one where all the signals worked.