Advertisement
azcoder1

Untitled

Oct 3rd, 2022
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | Source Code | 0 0
  1. from genericpath import isdir
  2. import os
  3.  
  4.  
  5. path = os.listdir(os.path.dirname(os.path.realpath(__file__)))
  6.  
  7. folder_path = "test/"
  8. if not os.path.isdir(folder_path):
  9.     os.mkdir(folder_path)
  10. i = 1
  11. for folder in path:
  12.     if folder == folder_path:
  13.         continue
  14.     if os.path.isdir(folder):
  15.         a = os.listdir(folder)
  16.         for file in a:
  17.             ap = os.path.realpath(folder) + "\\" + file
  18.             os.rename(ap, folder_path + str(i) + ".txt")
  19.  
  20.     i = i+1
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement