Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Arrange Photos into directories per day
import os
from datetime import datetime
for file in os.listdir("."):
if file.endswith(".jpg") or file.endswith(".3gp"):
date = datetime.strptime(file.split("_", 2)[1], '%Y%m%d')
datestr = date.strftime('%m/%d/%Y')
print(file + " " + datestr)
directory = os.path.join(os.getcwd(), date.strftime('%Y') + "-" + date.strftime('%m') + "-" + date.strftime('%d'))
if not os.path.exists(directory):
os.rename (os.path.join(os.getcwd(), file), os.path.join(directory, file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.