Skip to content

Instantly share code, notes, and snippets.

@jpoehnelt
Created June 9, 2014 07:04
Show Gist options
  • Save jpoehnelt/0f58d0702a93d50542fa to your computer and use it in GitHub Desktop.
Save jpoehnelt/0f58d0702a93d50542fa to your computer and use it in GitHub Desktop.
hash by start by alphabet
from os import listdir
from os.path import isfile, join
import shutil
def moveDirectory(src, dest):
try:
shutil.move(src, dest)
# Directories are the same
except shutil.Error as e:
print('Directory not copied. Error: %s' % e)
# Any error saying that the directory doesn't exist
except OSError as e:
print('Directory not copied. Error: %s' % e)
mypath = 'D:/Music'
for f in listdir(mypath):
if not isfile(join(mypath,f)) and len(f) > 1:
moveDirectory(join(mypath,f),''.join(['D:/Music','/',f[0],'/',f]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment