copyfile.py 812 B

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. import shutil
  3. import os
  4. currentPath = os.getcwd().replace('\\','/') # 获取当前路径
  5. # def file_name(file_dir):
  6. # for root, dirs, files in os.walk(file_dir):
  7. # print(root) #当前目录路径
  8. # print(dirs) #当前路径下所有子目录
  9. # print(files) #当前路径下所有非目录子文件
  10. newpath = currentPath + r"/new"
  11. os.makedirs(newpath)
  12. datanames = os.listdir(currentPath)
  13. list = []
  14. for i in datanames:
  15. nameList = i.split("&")
  16. if(len(nameList) > 1):
  17. for j in range(4) :
  18. newName = nameList[0] + "lv" + str(j) + "&" + nameList[1]
  19. shutil.copy(currentPath +r"/" + str(i),newpath+ r"/" +newName)
  20. # list.append(i)
  21. # print(list)
  22. # file_name(currentPath)
  23. # num_input = input('成功了,输入任意数字按回车退出')