Copying, Moving and Renaming Files Safely

shutil.copy2 copies a file, shutil.move and Path.rename move and rename one, and three habits keep a file-moving script safe, a backup copy, a check that the destination is free, and a dry run that shows the plan before anything moves.

By

Updated

Cheat sheet: Copying, Moving and Renaming Files Safely
Category
Python
Level
Journeyman
Tags
backup, dry-run, Idempotent, python, shutil