Created
March 19, 2019 02:26
-
-
Save antlauzon/a9edd96cf7c9876a8b1505f706a40005 to your computer and use it in GitHub Desktop.
Update your Ableton ALS file modified dates
This file contains hidden or 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
#!/usr/bin/env python3 | |
import glob | |
import gzip | |
import logging | |
import multiprocessing | |
import os | |
import re | |
import sys | |
MODDATE_RE=re.compile("\s*<LastModDate Value=\"(\d+)\".") | |
def update_times(als): | |
try: | |
largest_timestamp = 0 | |
with gzip.open(als, 'rb') as xml_file: | |
xml = xml_file.read() | |
for timestamp in MODDATE_RE.findall(str(xml), re.DOTALL): | |
timestamp = int(timestamp) | |
if timestamp > largest_timestamp: | |
largest_timestamp = timestamp | |
if largest_timestamp > 0: | |
os.utime(als, times=(largest_timestamp, largest_timestamp)) | |
except: | |
logging.error("ERROR: {}".format(als)) | |
return 0 | |
with multiprocessing.Pool(processes=16) as pool: | |
pool.map(update_times, | |
glob.iglob("{}/**/*.als".format(sys.argv[1]), recursive=True)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment