Python Forum
Looking through files in explorer in order? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Looking through files in explorer in order? (/thread-16495.html)



Looking through files in explorer in order? - stroudie2 - Mar-02-2019

Hi everyone. I'm pretty new at Python, and am struggling with something. As you can see from the image attached, I am trying to re-name all the files in a particular folder to fit a pattern for a project I'm making. Before running the code, the images are all named "testimage(i), i being the number in the folder. The problem I have is that while this code does run, and does rename them the way I want. The order in which it is going through them is weird. It seems to do the first one called "testimage(1)", followed by "testimage(10)", through to 19, then it just starts getting like evry tenth number first. I'm really confused why this is happening, but essentially I want it to just go through the images in the order they appear in the explorer. Any suggestions would be really great. Thanks!

[Image: 4d4760a62decc6dbbd873a690411b731]