Wrote my first little Python script to rename 60 photos, and it renamed the wrong ones twice before I figured out why | Coding For Beginners - Guest Forum
Wrote my first little Python script to rename 60 photos, and it renamed the wrong ones twice before I figured out why
I've been doing the free Codecademy Python lessons for about 3 weeks and decided to try something real instead of another lesson. I had 60 photos from my sister's birthday in Chicago all named stuff like IMG_4471.jpg, so I wrote a tiny loop to rename them birthday_01, birthday_02, and so on. Ran it, and it skipped numbers and doubled up on others, because the loop was renaming files while still reading the same folder and it kept grabbing files it had already touched. I learned I have to sort the list first and save all the new names before changing anything, which took me a whole evening to figure out. Does anyone have a good beginner habit for testing stuff like this on a copy first? I got lucky that nothing got deleted.