You can rename a directory in Python by moving it using the shutil module. The shutil.move(src, dst) moves the directory from src to dst. If you just change the name of the directory without specifying the path, you'll basically be renaming it.
>>> import shutil >>> shutil.move('my_folder', 'new_name')
The above code renames my_folder to new_name. You could also use the os.rename(src, dst) for renaming directories.
>>> import os >>> os.rename('my_folder', 'new_name')