Biao J.'s Online Portfolio

Organize Your Screenshot PNG Files by Adding Timestamps

Introduction

If you frequently take screenshots, you might have noticed that when these files are uploaded to cloud storage services like Dropbox, they can become disorganized. This is because screenshots often lack proper creation timestamps in their metadata, causing all files to appear as if they were created on the upload date. This post introduces a solution to this problem using a Python script that adds accurate creation timestamps to the EXIF metadata of your PNG files.

The Problem

Screenshots are a convenient way to capture important information quickly. However, when you upload these screenshots to cloud storage services such as Dropbox, they often lack the proper creation timestamp in their metadata. As a result:

  • Disorganization: Screenshots appear as if they were all taken on the same day, making it difficult to locate specific images.
  • Clutter: Cloud storage services display all recently uploaded screenshots together, even if they were initially taken years apart.
  • Inaccurate Sorting: Screenshots are sorted by upload date rather than the actual date, leading to confusion.

The Solution

To solve this issue, we created a Python script that extracts timestamps from screenshot filenames and updates the EXIF metadata and file modification times. This ensures that your screenshots are organized correctly according to when they were actually taken, not just when they were uploaded.

How It Works

The script processes PNG files, extracts timestamps from their filenames, and updates the EXIF metadata fields DateTimeOriginal and DateTimeDigitized. It also adjusts the file modification time to include the correct timezone offset.

Supported Filename Patterns

The script supports the following filename patterns to extract timestamps:

  1. screenshot_YYYY-MM-DD-HH-MM-SSpng_XXXXXXXXXXX.png (Google Photos make this)
  2. Screenshot YYYY-MM-DD at HH.MM.SS.png (usually made by Mac)

Features

  • Batch Processing: Process all PNG files in a specified folder.
  • Single File Processing: Process a single PNG file.
  • Timezone Adjustment: Automatically adjusts timestamps to the specified timezone.

Usage

Command-Line Arguments

  • path: Path to a folder or a single PNG file.
  • --timezone: Timezone for file modification time (default: Europe/Stockholm).
  • --batch: Process all PNG files in the folder (default: True).

Examples

Batch Processing (All PNG Files in a Folder)

To process all PNG files in a folder with the default timezone (Europe/Stockholm):

python timestamp_to_exif.py /path/to/folder --batch

To specify a different timezone:

python timestamp_to_exif.py /path/to/folder --batch --timezone America/New_York

Single File Processing

To process a single PNG file with the default timezone (Europe/Stockholm):

python timestamp_to_exif.py /path/to/file.png --batch False

To specify a different timezone:

python timestamp_to_exif.py /path/to/file.png --batch False --timezone America/New_York

Conclusion

By adding accurate timestamps to the EXIF metadata of your screenshot PNG files, this script ensures that your images are properly organized and easy to find in your cloud storage. Say goodbye to cluttered Dropbox folders and enjoy a more streamlined, efficient way of managing your screenshots.

Get the Script

You can find the timestamp_to_exif.py script and detailed instructions here.