Codes

Reformat the Images

Python Codes:

import os
os.chdir("beautiful_faces\\caucasian\\male")
# list all files
files = os.listdir(".")    
for filename in files:
    portion = os.path.splitext(filename)
    if portion[1] != ".jpg":    
        newname = "x"+ portion[0] + ".jpg"   
        os.rename(filename,newname)

Rename the Images

Python Codes:

import os
os.chdir("beautiful_faces\\caucasian\\male")
files = os.listdir(".") 
n = 0
for filename in files:
    portion = os.path.splitext(filename)  
    newname = str(n + 1) + ".jpg"  
    os.rename(filename,newname)
    n += 1
Kathleen Li

发表回复

您的电子邮箱地址不会被公开。