# rename **Repository Path**: Mr-Format/rename ## Basic Information - **Project Name**: rename - **Description**: Python批量重命名文件 - **Primary Language**: Python - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-05-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # rename #### 介绍 Python批量重命名文件 ```py import os path = 'D:\\example' files = os.listdir(path) index = 0 s = [] for file in files: last = '.' + file.split('.')[1] print(last) old_name = os.path.join(path, file) new_file = str(index) + last new_name = os.path.join(path, new_file) os.rename(old_name, new_name) index = index + 1 print(index) ```