# 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.

![Cheat sheet: Copying, Moving and Renaming Files Safely](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/104859357598445694ef268c2c15c256.webp)

- Category: Python
- Level: Journeyman
- Tags: backup, dry-run, Idempotent, python, shutil
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/python-automation-copy-move-rename-cheat-sheet
