Skip to content

Instantly share code, notes, and snippets.

@wridgers
Created February 6, 2013 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wridgers/4723642 to your computer and use it in GitHub Desktop.
Save wridgers/4723642 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import os, time, sys
now = time.time()
errorFiles = open('errors.txt', 'w')
playlist01days = open('Last 1 day.m3u', 'w')
playlist07days = open('Last 7 days.m3u', 'w')
playlist14days = open('Last 14 days.m3u', 'w')
playlist28days = open('Last 28 days.m3u', 'w')
for root, dirs, files in os.walk(os.getcwd()):
for filename in files:
if filename.endswith(('.mp3', '.flac', '.ogg')):
try:
path = os.path.join(root, filename)
created = os.path.getctime(path);
if (created > now - 60 * 60 * 24):
playlist01days.write(path + '\n')
if (created > now - 7 * 60 * 60 * 24):
playlist07days.write(path + '\n')
if (created > now - 14 * 60 * 60 * 24):
playlist14days.write(path + '\n')
if (created > now - 28 * 60 * 60 * 24):
playlist28days.write(path + '\n')
except:
errorFiles.write(path + '\n')
errorFiles.close()
playlist01days.close()
playlist07days.close()
playlist14days.close()
playlist28days.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment