33 lines
944 B
Python
33 lines
944 B
Python
import os
|
|
import shutil
|
|
|
|
folder_path = 'G:\\obj_fix\print'
|
|
|
|
# 遍历文件夹下的所有文件
|
|
# 定义函数来递归遍历文件夹下的所有文件
|
|
def list_files(directory):
|
|
for root, dirs, files in os.walk(directory):
|
|
for file in files:
|
|
yield os.path.join(root, file)
|
|
|
|
nums = 0
|
|
for file_path in list_files(folder_path):
|
|
if "_preview.png" not in file_path:
|
|
continue
|
|
print(file_path)
|
|
nums += 1
|
|
# #提取pid
|
|
# arrTemp = file_path.split('\\')
|
|
# pid = arrTemp[len(arrTemp)-2]
|
|
|
|
# #判断 G:\obj_fix\print\wrong\ 文件夹里 是否存在 {pid}_preview.png 文件
|
|
|
|
# filePath = f'G://obj_fix\print\wrong\{pid}_preview.png'
|
|
# #不存在跳过
|
|
# if not os.path.exists(filePath):
|
|
# continue
|
|
|
|
# #存在的话就重命名文件
|
|
# new_file_path = f'G://obj_fix\print\wrong\{pid}_preview_already_right.png'
|
|
# os.rename(filePath, new_file_path)
|
|
print(nums) |