txt 파일 이름 바꾸기

배치 파일은 TXT 이름 바꾸기

import os
path1 = 'INbreast/FILENEW-TRUE'
path2 = 'INbreast/CC_image/CC'
path3 = 'INbreast/txt/CC'
f = 1
files1 = os.listdir(path1)
files2 = os.listdir(path2)
for file1 in files1:
    for file2 in files2:
        if file1[:8] in file2:
            if 'cal' in file1:
                os.rename(os.path.join(path1, file1), os.path.join(path3, file2[:-5]+'-cal.txt'))
            else:
                os.rename(os.path.join(path1, file1), os.path.join(path3, file2[:-5]+'-mass.txt'))
게시 된 315 개 원래 기사 · 원 찬양 119 · 전망 110 000 +

추천

출처blog.csdn.net/w144215160044/article/details/104915650