SHARE
TWEET

auto

a guest Nov 12th, 2019 79 in 4 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Documentos (.docx, .xlsx, .pptx, .pdf)
  2. # Imagens (.jpg, .png)
  3. # Outros
  4. import os
  5. import sys
  6. import shutil
  7.  
  8. dir = sys.argv[1] #input("Digite o caminho do local para organizar: ")
  9. items = os.listdir(dir)
  10.  
  11. paths = []
  12. for item in items:
  13.     paths.append(os.path.join(dir, item))
  14.  
  15. os.mkdir(os.path.join(dir, "Documentos"))
  16. os.mkdir(os.path.join(dir, "Imagens"))
  17. os.mkdir(os.path.join(dir, "Outros"))
  18.  
  19. for path in paths:
  20.     if os.path.isfile(path):
  21.         extension = os.path.splitext(path)[1]
  22.        
  23.         if extension in [".docx", ".xlsx", ".pptx", ".pdf"]:
  24.             shutil.move(path, os.path.join(dir, "Documentos"))
  25.  
  26.         elif extension in [".jpg", ".jpeg", ".png"]:
  27.             shutil.move(path, os.path.join(dir, "Imagens"))
  28.  
  29.         elif extension in [".deb", ".jpeg", ".png"]:
  30.             shutil.move(path, os.path.join(dir, "Executáveis"))
  31.  
  32.         else:
  33.             shutil.move(path, os.path.join(dir, "Outros"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top