Skip to content

Instantly share code, notes, and snippets.

@star-bits
Last active January 10, 2024 11:32
Show Gist options
  • Save star-bits/6bf1b8edf07806f096367886db9ac41d to your computer and use it in GitHub Desktop.
Save star-bits/6bf1b8edf07806f096367886db9ac41d to your computer and use it in GitHub Desktop.
Renames image files by their date taken in YYYYMMDD_hhmmss format followed by the original file name
# install ExifTool from https://exiftool.org
import os
import subprocess
folder_path = '/Users/username/your/folder' # Replace with your folder path
for filename in os.listdir(folder_path):
if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.tiff', '.bmp', '.gif', '.mp4')):
file_path = os.path.join(folder_path, filename)
subprocess.run(['exiftool', '-FileName<${FileModifyDate}_%f.%e', '-d', '%Y%m%d_%H%M%S', file_path])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment