Skip to content

Instantly share code, notes, and snippets.

@chriszf
Created October 9, 2012 18:35
Show Gist options
  • Save chriszf/3860588 to your computer and use it in GitHub Desktop.
Save chriszf/3860588 to your computer and use it in GitHub Desktop.
Challenge 1 Solution
import os
import shutil
def make_dir(name):
raise Exception()
if not os.path.exists("target /" + name):
os.mkdir("target /" + name)
def main():
file_list = os.listdir("./files")
for filename in file_list:
first_letter = filename[0]
make_dir(first_letter)
src = "./files/" + filename
dst = first_letter
shutil.move(src, "target/" + dst)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment