Last active
October 16, 2022 14:47
-
-
Save konverner/da356890ef1d8f1ac6419d307403e504 to your computer and use it in GitHub Desktop.
Rename batch of files in Windows directory with Python
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 | |
# here a path to a folder with files | |
PATH = r'C:\folder_to_rename' | |
# Filename extension | |
extension = '.png' | |
# in this case it numerates files from 0 to N, where N is a number of files. | |
i = 0 | |
for filename in os.listdir(PATH): | |
os.rename(PATH+'\\'+filename,PATH+'\\'+str(i)+extension) | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment