16
My first Python script deleted a folder I needed
I was in my project folder on my laptop, trying to automate cleaning up some files. I wrote a script to delete files ending in .tmp, but I used os.remove() on a folder by mistake. It wiped my 'assets' folder instantly. Has anyone found a good way to test delete commands safely before running them for real?
2 comments
Log in to join the discussion
Log In2 Comments
skylerc8614d agoTop Commenter
Saw a tip to always print the file list first with a dry run flag. I set up a test folder with dummy files now before any delete script runs for real.
7
claireg8114d ago
Honestly I just run the real command and pay attention. All that dry run stuff @skylerc86 mentioned just adds extra steps that can still go wrong. If you're careful with your path and double-check the line, it's fine.
7