Skip to content

Instantly share code, notes, and snippets.

@trofimovdev
Created January 4, 2021 23:48
Show Gist options
  • Save trofimovdev/fa4edced8f045e4173b91e5827c22650 to your computer and use it in GitHub Desktop.
Save trofimovdev/fa4edced8f045e4173b91e5827c22650 to your computer and use it in GitHub Desktop.
Takes the time from the filename and pastes into the utime
import os, time
import ffmpeg
from datetime import datetime
path = '/'
names = sorted(os.listdir(path))
files_counter = 0
for name in names:
if not name.lower().endswith('.mov'):
continue
info = os.stat(path + name)
vid = ffmpeg.probe(path + name)
date = datetime.fromisoformat(vid['streams'][0]['tags']['creation_time'].replace("Z", "+03:00")).timestamp()
os.utime(path + name, (date, date))
files_counter += 1
print(files_counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment