Skip to content

Instantly share code, notes, and snippets.

@AlexeyGy
Created June 3, 2022 20:54
Show Gist options
  • Save AlexeyGy/4d32d3187a6223caa7f814d4a40021d8 to your computer and use it in GitHub Desktop.
Save AlexeyGy/4d32d3187a6223caa7f814d4a40021d8 to your computer and use it in GitHub Desktop.
Fix pixel created date in FCPX when importing media.
import os
import argparse
import re
from datetime import datetime
import subprocess
parser = argparse.ArgumentParser(description='Restore creation dates')
parser.add_argument('dir', help='Directory to parse for PXL files.')
args = parser.parse_args()
expression = re.compile("PXL_(\d+)_(\d+).*.mp4")
for f in os.listdir(args.dir):
matched = expression.match(f)
if not matched:
continue
# example match 20220518_065748702 -> 2022-05-18 06:57:48.702000
dt = datetime.strptime(matched.group(1) + '_' +
matched.group(2), '%Y%m%d_%H%M%S%f')
print(dt, f)
subprocess.run(
f'SetFile -d "{dt.month}/{dt.day}/{dt.year} {dt.hour}:{dt.minute}" {os.path.join(args.dir, f)}', shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment