T
19

My first Python script deleted my entire 'Documents' folder

I was in my apartment in Chicago, trying to write a script to clean up old text files. I used 'os.remove' with a wildcard path, but I messed up the directory. Instead of targeting my 'temp_files' folder, it pointed to 'Documents'. In about two seconds, every photo and tax file from the last three years was gone. I panicked, but then remembered reading about the 'send2trash' module. I rewrote the script to use that instead, and now I test all my file paths in a dummy folder first. Has anyone else had a close call like that with file operations?
3 comments

Log in to join the discussion

Log In
3 Comments
dianas50
dianas502d ago
Lost a whole project folder once, brutal.
7
annanguyen
Ever try file recovery software like Recuva, @dianas50?
4
thomas.tyler
Honestly, the real scare is how fast it happens, no undo button.
1