Created
March 2, 2012 23:44
-
-
Save usami/1962465 to your computer and use it in GitHub Desktop.
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/bin/env python | |
#-*- coding: utf-8 -*- | |
""" | |
This is a script to organize your iTunes Music Library. | |
It moves all directories in the src directory to the destination directory (normally, the Automatically add to iTunes directory). | |
When they are put in the Automatically add to iTunes directory, iTunes adds them to the library automatically. | |
""" | |
import os, sys, shutil | |
ESCAPE_DIR = ['Audiobooks', | |
'Automatically Add to iTunes', | |
'Books', | |
'Downloads', | |
'Friends', | |
'Mobile Applications', | |
'Movies', | |
'Music', | |
'Podcasts', | |
'iTunes U'] | |
if len(sys.argv) != 3: | |
print 'Usage: python %s [src dir] [dst dir]' % sys.argv[0] | |
sys.exit() | |
else: | |
src_dir = sys.argv[1] | |
dst_dir = sys.argv[2] | |
if not os.path.exists(src_dir): | |
sys.exit() | |
else: | |
for root, dirs, _ in os.walk(src_dir): | |
for name in dirs: | |
if name not in ESCAPE_DIR and not name.startswith('.'): | |
shutil.move(root + name, dst_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment