Skip to content

Instantly share code, notes, and snippets.

@danielkza
Created February 12, 2013 21:27
Show Gist options
  • Save danielkza/4773552 to your computer and use it in GitHub Desktop.
Save danielkza/4773552 to your computer and use it in GitHub Desktop.
import os
import shutil
rootDir = 'G:/testasd/'
print('[',rootDir,']')
for (dirPath, dirNames, fileNames) in os.walk(rootDir):
for file in fileNames:
root, ext = os.path.splitext(file)
if ext not in ('.mp3', '.flac', '.m4a'):
src = os.path.join(dirPath, file)
dest = os.path.join(dirPath, file + '.mp3')
ok = True
try:
shutil.move(src,dest)
except Exception:
ok = False
print("{0:40} => {1:40} [{2}]".format(os.path.relpath(src, rootDir), os.path.relpath(dest, rootDir), 'OK' if ok else 'ERROR'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment