Date filtering doesn’t work? Check your photos for valid Exif date information

If you want to use the date filtering capabilities of Pi3D PictureFrame using Home Assistant, you need your photos to contain valid Exif data information.

Here is a small Python script to identify all jpg that do not contain proper Exif date information.

I wrote a longer post on this subject here, but I wanted to make an update with the latest Raspberry Pi operating system.

I recommend reading the original post to get more background information on how it works.

Tested with Raspberry Pi OS Bookworm (Oct 2023) on a Raspberry Pi 4.

The updated python script

Installing and running this script is straightforward.

Create a new file called “” with the code below.

#!/usr/bin/env python3

import os
from PIL import Image
from PIL.ExifTags import TAGS

def has_exif_date(image_path):
        img =
        exif_data = img._getexif()
        if exif_data:
            for tag, value in exif_data.items():
                tag_name = TAGS.get(tag, tag)
                if tag_name == 'DateTimeOriginal':
                    return True
        return False
    except (AttributeError, OSError):
        return False

def list_images_without_exif_date(folder_path):
    for root, dirs, files in os.walk(folder_path):
        for file in files:
            if file.lower().endswith(".jpg"):
                image_path = os.path.join(root, file)
                if not has_exif_date(image_path):
                    print(f"No EXIF date in: {image_path}")

if __name__ == "__main__":
    folder_path = "photos"  # Replace with the path to your "photos" folder

Specify your photos folder at the bottom of the script and save it.

Put this file into the home directory of your Raspberry Pi.

To run the script, enter


The output will be printed in the Terminal window, and you can fix those files in Adobe Lightroom or whatever image manipulation software you use.

No EXIF date in: photos/IMG_2329 2.jpg
No EXIF date in: photos/1990. 05.05 - 11.57. 18.jpg
No EXIF date in: photos/IMG_2329.jpg

Good photo maintenance makes for a great digital picture frame experience. A little effort goes a long way!

Was this article helpful?

Thank you for your support and motivation.

Scroll to Top