#encoding=utf-8
import glob
import os
import shutil
if __name__ == "__main__":
dir = r'D:\superresolution\DF2KOST\train'
dir_dst = r'D:\superresolution\DF2KOST_data'
filepaths = glob.glob(r"D:\superresolution\DF2KOST\train\*\*.png") + \
glob.glob(r"D:\superresolution\DF2KOST\train\*\*\*.png")
print(len(filepaths))
index = 0
for file in filepaths[:0]:
filename = file.split('\\')[-1]
print(file, filename)
file3 = os.path.join(dir_dst, f"{index:05d}.jpg")
shutil.copy(file, file3)
# file2 = os.path.join(dir_dst, filename)
# file3 = os.path.join(dir_dst, f"{index:5d}.jpg")
# print(file2, file3)
# os.rename(file, file3)
index += 1
获取目录及其子目录文件
最新推荐文章于 2024-08-15 01:55:01 发布