Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import os
def get_list():
all_name = os.listdir()
return all_name
n = 11
cafeIndex = '2342'
#對所有的檔案名稱做 for 迴圈,訂定你的命名規則
for i in get_list():
path = '1-' + cafeIndex + '-' + str(n) + '.png'
#如果你的檔案夾裡面不只有照片,也有其他類型的檔案,用 if 把照片挑出來
if '.png' in i:
os. rename(i , path)
n = n+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment