Skip to content

Instantly share code, notes, and snippets.

@adamloving
Created October 30, 2011 23:47
Show Gist options
  • Save adamloving/1326599 to your computer and use it in GitHub Desktop.
Save adamloving/1326599 to your computer and use it in GitHub Desktop.
Moving some mp3 files around
import shutil, os, os.path
root = '/Volumes/Blackmagic/Music/'
dest = '/Volumes/Blackmagic/90bpm/'
f = open('working.m3u')
s = f.read()
files = s.split('\n')
i = 0
for filename in files:
i = i + 1
dest_filename = filename.replace(root, dest)
if os.path.exists(dest_filename):
print "Path exists %s" % dest_filename
else:
try:
os.makedirs(dest_filename)
except:
print 'failed to create dir (prob already exists)'
if os.path.exists(dest_filename):
print "%s skipping %s" % (i, dest_filename)
else:
print "%s %s" % (i, dest_filename)
try:
shutil.copy2(filename, dest_filename)
except:
print "failed to copy file %s" % dest_filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment