Created
July 13, 2023 21:01
-
-
Save Edwardtonnn/b10c978314507f8d842dea7f51099b13 to your computer and use it in GitHub Desktop.
Rename Png images to sequence
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 rename_images(): | |
image_files = [f for f in os.listdir() if f.endswith('.png')] | |
image_files.sort() | |
for i, filename in enumerate(image_files): | |
new_filename = '{:02d}.png'.format(i + 1) | |
os.rename(filename, new_filename) | |
print('Renamed {} to {}'.format(filename, new_filename)) | |
rename_images() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment