Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def DirectoryCleaner():
  2.     dir = input("Enter absolute path to directory. ")
  3.     extensions = []
  4.     confirm = input("Are you sure you want to execute this task? ")
  5.     if confirm == 'y' and dir:
  6.         print("Sorting {}".format(dir))
  7.         files = os.listdir(dir)
  8.         for file in files:
  9.             ext = os.path.splitext(file)[1]
  10.             if ext not in extensions:
  11.                 createExtensionDirectory(dir, ext)
  12.                 extensions.append(ext)
  13.             moveFile(dir, file, ext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement