12
Wrote a Python script to rename 500 files, ended up deleting them all instead
Was trying to clean up my downloads folder last night. Had like 500 screenshots with random names. Found a tutorial on using os.rename in a loop. Typed it out, ran it, and poof. Everything gone. Turns out I used os.remove instead. Learned to always test on 3 files first before running on the whole batch. Anyone else made a similar copy/paste mistake?
2 comments
Log in to join the discussion
Log In2 Comments
barbara_moore7316d ago
Oh man, I heard someone say they keep a test folder with three dummy files for exactly this reason. Your mileage may vary but that tip saved me after a similar oopsie.
5
leebrown16d ago
Funny how that works, isn't it? We all learn the hard way that a little bit of planning saves a lot of pain later. It's like how people who double check their locks before a vacation never get broken into, and people who don't are the ones who come home to a mess. That test folder trick is basically the digital version of having a spare tire in your trunk. You don't think you'll need it until you're stuck on the side of the road staring at a flat. Seems like half of life is just figuring out which small habits keep you from the big headaches.
2