Can I rename a folder?

094

Yes, you can rename a folder in Python using the os.rename() function. Here’s an example:

import os

# Specify the current folder name and the new folder name
current_folder_name = 'old_folder_name'
new_folder_name = 'new_folder_name'

# Rename the folder
os.rename(current_folder_name, new_folder_name)

Make sure that the folder you want to rename exists, and that the new folder name does not already exist to avoid errors.

0 Comments

no data
Be the first to share your comment!