Advertisement
mayankjoin3

Folder Copy Paste arrange for assignment Split Folder

Nov 26th, 2022
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sun Oct 24 13:57:30 2021
  4.  
  5. @author: Sanjit
  6. """
  7.  
  8. import os
  9. import glob
  10. import shutil
  11.  
  12. i = 1
  13. for i in range(1,17):
  14.     tFile = 'tut'+'%02d'%i
  15.     if(not os.path.exists(tFile)):
  16.         os.mkdir(tFile)
  17.     for file in glob.glob("cs384_2021_21-11_Sanjit_t6/*"):
  18.         # print(file)
  19.         # if(not os.path.exists(tFile+'\\'+file.split('\\')[-1])):
  20.         #     os.mkdir(tFile+'\\'+file.split('\\')[-1])
  21.         for innerFile in glob.glob(file+'/*'):
  22.             # print(innerFile)
  23.             if (innerFile.split('\\')[-1] == tFile):
  24.                 try:
  25.                     shutil.copytree(innerFile, tFile+'\\'+file.split('\\')[-1])
  26.                 except:
  27.                     pass
  28.     print(tFile)
  29.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement