Category: shutil

Problem

Duplicate a folder recursively.

Solution

  shutil.copytree("src", "backup/src", dirs_exist_ok=True)
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path