Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. import os, shutil
  2.  
  3. path = "C:/Users/amady/Downloads/"
  4. toExe = path + "exe_and_msi/"
  5. toVideos = path + "videos/"
  6. toAudio = path + "audio/"
  7. toImages = path + "images/"
  8. toTorrents = path + "torrents/"
  9. toZip = path + "zip/"
  10. toDocuments = path + "documents/"
  11. toJar = path + "jar/"
  12. toIso = path + "iso/"
  13.  
  14. def move(place, f):
  15.     src = path + f
  16.     dst = place + f
  17.     shutil.move(src, dst)
  18.  
  19. os.chdir("C:/Users/amady/Downloads")
  20.  
  21. for f in os.listdir():
  22.     fileExtension = os.path.splitext(f)[1].split(' ')[0]
  23.     if fileExtension in [".exe", ".msi"]:
  24.         move(toExe, f)
  25.     elif fileExtension in [".mp4", ".avi", ".AVI", ".MOV", ".mov"]:
  26.         move(toVideos, f)
  27.     elif fileExtension == ".torrent":
  28.         move(toTorrents, f)
  29.     elif fileExtension in [".mp3", ".wav"]:
  30.         move(toAudio, f)
  31.     elif fileExtension in [".png", ".jpg", ".nef", ".jpeg"]:
  32.         move(toImages, f)
  33.     elif fileExtension == ".zip":
  34.         move(toZip, f)
  35.     elif fileExtension in [".docx", ".doc", ".ppt", "pptx"]:
  36.         move(toDocuments, f)
  37.     elif fileExtension == ".jar":
  38.         move(toJar, f)
  39.     elif fileExtension == ".iso":
  40.         move(toIso, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement