In the previous section, we learned how we can use shutil.move() to move files from source to destination. Using shutil.move(), files can be renamed. Create a shutil_rename_example.py script and write the following content in it:
import shutil
shutil.move('hello.py', 'hello_renamed.py')
Run the script as follows:
$ python3 shutil_rename_example.py
Output:
Now, check that your filename will be renamed hello_renamed.py.