Skip to content

Instantly share code, notes, and snippets.

@hehehaha0228
Last active June 28, 2018 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hehehaha0228/d4d84a97be9641c95f0e7d398a31a3b2 to your computer and use it in GitHub Desktop.
Save hehehaha0228/d4d84a97be9641c95f0e7d398a31a3b2 to your computer and use it in GitHub Desktop.
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