Advertisement
_DeCoDe

Project 1 - Sort Image and muzic

Jun 12th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. #Acest script cauta fisiere .mp3 si le muta in folderul muzica
  2. import os
  3. import time
  4. import sys
  5. import shutil
  6.  
  7.  
  8. def principal ():
  9.     print("--------S T A R T--------")
  10.     alege = input ("Ce doresti sa sortezi? (imagini/muzica) ")
  11.     if alege == muzica:
  12.         muzica ()
  13.     elif alege == imagini:
  14.         imagini ()  
  15.  
  16. path = "/sdcard/Download"
  17. list = os.listdir(path)
  18. count = 0
  19.  
  20. def imagini():
  21.     try:
  22.         file = os.mkdir('/sdcard/Download/imagini')
  23.     except OSError:
  24.         print ("fișierul exista")
  25.     for file in list:
  26.        extensie = file.endswith (".png")
  27.        extensie2 = file.endswith(".jpg")
  28.        extensie3 = file.endswith (".gif")
  29.        if extensie == True or extensie2 == True or extensie3 == True:
  30.            shutil.move ('/sdcard/Download/' + file, '/sdcard/Download/imagini')
  31.        
  32.            print("DONE")
  33.          
  34.          
  35. def muzica ():
  36. #Aceasta functie sorteaza muzica
  37.     try:
  38.         filemusic = os.mkdir ('/sdcard/Download/muzica')
  39.     except OSError:
  40.         print ("Fisierul muzica exista deja")
  41.    
  42.    
  43.     for file in list:
  44.         extensie = file.endswith('.mp3')
  45.         if extensie == True:
  46.             shutil.move ("/sdcard/Download/" + file, "/sdcard/Download/muzica")
  47.             count +=1        
  48.             print("Toate fisierele mp3 au fost mutate in folderul muzica")
  49.             print("Au fost transferate", count, "fisiere")            
  50.             print ("DONE")  
  51.            
  52. if __name__ == '__main__':
  53.     principal()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement