9
Warning: My first Python script deleted my entire downloads folder
I was in my dorm room at college trying to write a script to clean up old files. I used os.remove() on a folder path but messed up the string, so it targeted the whole downloads directory instead of a subfolder. I panicked and shut my laptop down, but it was too late. I spent the next two hours trying to recover stuff from the recycle bin, which only had some of it. Has anyone else done something this dumb with file paths, and what's the safest way to test scripts that delete things?
4 comments
Log in to join the discussion
Log In4 Comments
jennyfisher22d ago
Deleted downloads" isn't the end of the world, honestly.
7
the_sage22d ago
Tell me about it. My downloads folder is basically a digital graveyard for tax forms I meant to file and recipes I'll never cook. I once accidentally deleted a whole folder of vacation photos from there. Had to dig through the recycling bin like an archaeologist on a bad dig.
5
emeryo5822d ago
Okay but "isn't the end of the world" is doing a lot of work there. What about when you delete the wrong thing because you're just cleaning out old downloads? I had a friend who wiped a folder of work files she needed because she thought it was just old junk. Took her a whole day to get it back from IT.
5
spencerross20d ago
Digital graveyard for tax forms" is way too real. Jennyfisher, you clearly have never had to explain to your boss why the quarterly report is gone.
1