When working with servers you mostly get a terminal to perform different functions. Sometimes you need to write a different script that requires you to rename a file or directory. Letās take a look at how to rename a file and directory using Python āosā library.
There is a python built-in function os.rename(src, dest) that take two arguments source location of the file or directory and destination location of the file or directory.
Renaming File
Letās run the following code.
import os |
Renaming Directory
Now letās rename the directory. Renaming directory is same as renaming file.
Letās execute the following code to rename the directory.
import os |























