Skip to content

Instantly share code, notes, and snippets.

@meikj
Last active December 20, 2015 00:29
Show Gist options
  • Save meikj/6041720 to your computer and use it in GitHub Desktop.
Save meikj/6041720 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from os import listdir, mkdir
from os.path import isfile, join
from shutil import move
PATH = "D:/Videos/Movies/"
def main():
files = [ f for f in listdir(PATH) if isfile(join(PATH, f)) ]
folders = [ f.split('.')[0] for f in files ]
print("The following folders will be created (%s):" % PATH)
for i, f in enumerate(folders):
print("\t%d. %s" % (i + 1, f))
if raw_input("Continue with procedure (Y/N)? ").lower() == 'y':
# continue with procedure
print
for f, folder in zip(files, folders):
src, dst = (PATH + f, PATH + folder + '/')
print("%s -> %s" % (src, dst))
mkdir(dst)
move(src, dst)
else:
exit()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment