Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created November 10, 2011 14:42
Show Gist options
  • Save Eugeny/1354999 to your computer and use it in GitHub Desktop.
Save Eugeny/1354999 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import glob
import os
import sqlite3
try:
format = sys.argv[1]
except:
format = 'artist - title'
for dbf in glob.glob('*.db'):
db = sqlite3.connect(dbf)
c = db.cursor()
c.execute('select * from music where LocalCopyPath is not null')
for row in c:
name = format.replace('title', row[11]).replace('album', row[12]).replace('artist', row[13])
name += '.mp3'
try:
os.renames('%i.mp3'%row[0], name)
print '\n%s : %i = %s\n'%(dbf,row[0],name),
except:
print '.',
print '\ndone'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment