I recently wrote a Python script to back up web pages I downloaded from Chrome. I wanted to make sure I had copies in case the originals were deleted. The problem is, I made a mistake with the file paths when copying the files. My program was set up like this:
```
shutil.copy(absolute_filename, absolute_dir)
```
Unfortunately, I entered the wrong source filename, which caused the files to be moved from the Chrome download location to a different directory. Now I've lost about 70 of my downloaded web pages. Does anyone have suggestions for best practices to prevent this from happening again?
3 Answers
Definitely consider implementing a dry run option in your scripts. This way, the script will show you what it intends to do without actually moving or deleting any files. That can save you a lot of headaches!
You should also run tests that just report what the script will do instead of executing it right away. It can help catch any major mistakes before they impact your files.
Oof, that sounds frustrating! One tip is to add a confirmation step to your scripts. For example, include a print statement that shows the directories you're working with and then have a prompt like 'press enter to continue' before executing the move. It helps catch mistakes before it's too late.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically