Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import shutil
  2. shutil.copy('C:\111.pdf','C:\Папка1\111.pdf') # копировать
  3. shutil.copy('C:\111.pdf','C:\Папка2\111.pdf')
  4. print ('готово!')
  5.  
  6. for path in Path('/source-dir').iterdir():
  7. if path.is_file():
  8. shutil.copy(str(path), str(dest_dir))
  9.  
  10. import shutil
  11. import os
  12. files_list=os.listdir('C:/test/')
  13. i=0
  14. for lin in files_list:
  15. files_list[i]='C:/test/'+lin
  16. i+=1
  17. i=0
  18. for n in files_list:
  19. a=os.path.splitext(files_list[i])
  20. print(a)
  21.  
  22. if a[1] == '.txt':
  23. shutil.move(files_list[i], 'C:/test/doc/')
  24. elif a[1] == '.doc':
  25. shutil.move(files_list[i], 'C:/test/doc/')
  26. elif a[1] == '.pdf':
  27. shutil.move(files_list[i], 'C:/test/doc/')
  28. elif a[1] == '.pptx':
  29. shutil.move(files_list[i], 'C:/test/doc/')
  30. elif a[1] == '.docx':
  31. shutil.move(files_list[i], 'C:/test/doc/')
  32. elif a[1] == '.png':
  33. shutil.move(files_list[i], 'C:/test/img/')
  34. elif a[1] == '.jpg':
  35. shutil.move(files_list[i], 'C:/test/img/')
  36. elif a[1] == '.jpeg':
  37. shutil.move(files_list[i], 'C:/test/img/')
  38. elif a[1] == '.bmp':
  39. shutil.move(files_list[i], 'C:/test/img/')
  40. i+=1
  41.  
  42. import os
  43. import shutil
  44.  
  45. folder_from = 'C:\Test_Files'
  46. folder_to = 'C:\Users_Files'
  47. folder_user_list = ('User1', 'User2')
  48.  
  49. for f in [f for f in os.listdir(folder_from) if os.path.isfile(os.path.join(folder_from, f))]:
  50. for folder_user in folder_user_list:
  51. shutil.copy(os.path.join(folder_from, f), os.path.join(folder_to, folder_user, f))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement