Last active
June 28, 2018 13:51
-
-
Save hehehaha0228/d4d84a97be9641c95f0e7d398a31a3b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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