I use Python 3.12.3 on WSL2 Ubuntu. The following code renames the file test.py to test2.py without copying the initial file. Hence, I have only one file named test2.py
import os os.rename('./test.py', './test2.py')