Skip to content

Instantly share code, notes, and snippets.

@nb
Created April 17, 2009 16:39
Show Gist options
  • Save nb/97120 to your computer and use it in GitHub Desktop.
Save nb/97120 to your computer and use it in GitHub Desktop.
Copy files from an iTunes playlist to a directory
#!/usr/bin/env python
import sys, shutil, os.path
if len(sys.argv) != 3:
sys.stderr.write('Usage: %s PLAYLIST DEST\n\n' % sys.argv[0])
sys.exit(1)
exported, dest = sys.argv[1:]
lines = unicode(open(exported).read(), 'utf16').split('\r')[1:]
files = ['/Volumes/' + line.split('\t')[-1].replace(':', '/') for line in lines]
for file in files:
if os.path.exists(file) and os.path.isfile(file): shutil.copy(file, dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment