Code meaning: rename all files under
the path , and the result of the renaming is that the previous name is added before the namepath
png
zs_
import os
def rename(path):
filelist = os.listdir(path)
for item in filelist:
if item.endswith('.png'):
src = os.path.join(os.path.abspath(path), item)
dst = os.path.join(os.path.abspath(path), 'zs_' + item)
try:
os.rename(src, dst)
except:
continue
rename(path = "./label/")