Created
October 9, 2012 18:35
-
-
Save chriszf/3860588 to your computer and use it in GitHub Desktop.
Challenge 1 Solution
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
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