Advertisement
Guest User

Untitled

a guest
May 10th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import os, shutil, time
  2.  
  3. #Specify filetypes to be copied.
  4. doc=".rtf", ".txt", ".pdf", ".doc"
  5. pic=".bmp", ".jpg", ".png", ".tif", ".gif", ".rpg"
  6. #Specify directories
  7. my_space="D:/tmp/space"
  8. my_documents="D:/tmp/space/documents"
  9. my_pictures="D:/tmp/space/pictures"
  10.  
  11. cls="\n" * 100
  12.  
  13. def copy_doc():
  14.     pathname=os.path.join(my_space, basename)
  15.     if os.path.isfile(pathname):
  16.         shutil.copy2(pathname, my_documents)
  17.        
  18. def copy_pic():
  19.     pathname=os.path.join(my_space, basename)
  20.     if os.path.isfile(pathname):
  21.         shutil.copy2(pathname, my_pictures)
  22.  
  23. #Menu
  24. menu=True
  25. while menu:
  26.     print """***Copy Mate***\n
  27. 1. Copy files
  28. 2. Delete files\n"""
  29.     selection=input("Selection: ")
  30.     if selection==1:
  31.         for basename in os.listdir(my_space):
  32.             if basename.endswith(doc):
  33.                 copy_doc()
  34.             if basename.endswith(pic):
  35.                 copy_pic()
  36.     if selection==0:
  37.         print "Exiting..."
  38.         time.sleep(2)
  39.         menu=False
  40.     else:
  41.         print "Invalid input\n\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement