Created
November 13, 2022 02:19
-
-
Save Trimad/9c4eb5c35176912e0c8fc354c82d2fd2 to your computer and use it in GitHub Desktop.
Renames a folder of .png files to be sequential with leading zeros.
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 | |
import pathlib | |
collection = os.getcwd() | |
#print(collection) | |
for i, filename in enumerate(os.listdir(collection)): | |
file_extension = pathlib.Path(filename).suffix | |
#print("File Extension: ", file_extension) | |
if(file_extension == ".png"): | |
os.rename(collection +"\\"+ filename, collection +"\\"+ str(i).zfill(4) + ".png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment