專案

一般

配置概況

Bug #66 » rename.py

建誠 林, 2023-11-02 00:23

 
import os
path = "C:\\Users\\DELL\\Desktop\\NTUT_project\\whites_of_eyes_crop\\t"
files=os.listdir(path)
print(files)

n = 15 #�]�w��l��
p = 15
x = 0
for i in files: #�]����Ƨ��̭����ɮ׳��n���s�󴫦W��
if i.split('.')[1] == 'jpg':
oldname=path+'\\'+files[x] #���X�ɮײ{�b�����|�W�١A[n]���ܲ�n���ɮ�
newname=path+'\\'+"test"+str(n)+'.jpg'
os.rename(oldname,newname)
print(oldname+'>>>'+newname)
n=n+1
if i.split('.')[1] == 'png':
oldname=path+'\\'+files[x] #���X�ɮײ{�b�����|�W�١A[n]���ܲ�n���ɮ�
newname=path+'\\'+"test"+str(p)+'.png'
os.rename(oldname,newname)
print(oldname+'>>>'+newname)
p=p+1
x=x+1
(5-5/6)