Created
October 28, 2013 20:36
-
-
Save ideoforms/7204179 to your computer and use it in GitHub Desktop.
Python: Retrieve filename of currently-open Ableton Live set
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
#!/usr/local/bin/python | |
# Python: Retrieve filename of currently-open Ableton Live set | |
# based on inspecting Live's last Log.txt. | |
import re | |
import os | |
import glob | |
# Use Log.txt corresponding to latest Live version. eg: | |
# ~/Library/Preferences/Ableton/Live\ 9.0.6/Log.txt | |
root = os.path.expanduser("~/Library/Preferences/Ableton") | |
logfiles = glob.glob("%s/Live */Log.txt" % root) | |
regexp = "file://.*\.als$" | |
if logfiles: | |
logfile = list(sorted(logfiles))[-1] | |
# print "(using logfile %s)" % logfile | |
contents = file(logfile).readlines() | |
projects = filter(lambda line: re.search(regexp, line), contents) | |
project = projects[-1].strip() | |
project = os.path.basename(project) | |
print project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment