You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
|
|
import os |
|
import shutil |
|
#遍历 G:\obj_fix\print\wrong 文件 获取到pid |
|
|
|
workdir = 'G:\obj_fix\print' |
|
# output = 'G:\obj_fix\ply\whole_obj_bake_vertex_high_ply' |
|
directory = f'G:\obj_fix/print/wrong' |
|
#遍历获取 G:\obj_fix\print\right 目录的文件,根据文件名获取 pid |
|
|
|
arrWrongFiles = [] |
|
for file_name in os.listdir(directory): |
|
# # 获取文件的完整路径 |
|
# file_path = os.path.join(directory, file_name) |
|
# # 检查是否是文件 |
|
# if os.path.isfile(file_path): |
|
# # |
|
|
|
arrFileName = file_name.split('_') |
|
pid = arrFileName[0] |
|
if int(pid) == 0: |
|
continue |
|
|
|
arrWrongFiles.append(pid) |
|
|
|
#遍历 G:\obj_fix\print\preview 文件 获取到pid |
|
directory = f'G:\obj_fix/print/preview' |
|
for file_name in os.listdir(directory): |
|
arrFileName = file_name.split('_') |
|
pid = arrFileName[0] |
|
if int(pid) == 0: |
|
continue |
|
|
|
if pid in arrWrongFiles: |
|
continue |
|
|
|
#判断right目录中是否已经存在该pid的文件 |
|
if os.path.exists(f'G:\obj_fix/print/right/{file_name}'): |
|
continue |
|
|
|
print("new_pid",pid) |
|
#不在arrWrongFiles中的pid,就是正确的pid要复制到right目录 |
|
filePath = os.path.join(directory, file_name) |
|
shutil.copy(filePath, f'G:\obj_fix/print/right/{file_name}') |