Created
December 31, 2024 10:51
-
-
Save hctilg/848bed4aaa60de24da68a8eeff3d4a97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 re | |
images = [img for img in os.listdir(folder_path) if img.endswith(('.png', '.jpg', '.jpeg'))] | |
images.sort(key=lambda filename: [int(text) if text.isdigit() else text for text in re.split('([0-9]+)', filename)]) | |
print(images) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment