Created
January 4, 2021 23:48
-
-
Save trofimovdev/fa4edced8f045e4173b91e5827c22650 to your computer and use it in GitHub Desktop.
Takes the time from the filename and pastes into the utime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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