這系列圖片一次100張要改名
一張一張手動改費時傷神
一張一張手動改費時傷神
![image image](https://imageproxy.pixnet.cc/imgproxy?url=https://pic.pimg.tw/monkeyjhong/1642482647-4235886320-g_n.png&width=600&height=434)
![image image](https://imageproxy.pixnet.cc/imgproxy?url=https://pic.pimg.tw/monkeyjhong/1642482729-3444103036-g.png&width=224&height=51)
import os
# 取代成目標資料夾路徑
folder = "D:\leg_hair_taiwan\step2/nft-resize"
for count, filename in enumerate(os.listdir(folder)):
# 取名
# zfill是序號左邊補0 傳參數幾就補滿幾 ex zfill(3) 會把 1 變 001
dst = f"TaiwanLegHair #{str(count+1).zfill(3)}.png"
src =f"{folder}/{filename}" # foldername/filename, if .py file is outside folder
dst =f"{folder}/{dst}"
# rename() function will
# rename all the files
os.rename(src, dst)
文章標籤
全站熱搜