The purpose of the script below is to rename multiple folders in a directory. File is named 2324[folder 1], 3242343[Folder 2), 4343[folder 3]. The purpose of script is to rename files to keep only folder 1, folder 2, and folder 3 name. I currently have 20,000 folders to rename
when I print the script the code renames the files as intended however when I run the code it does not change the names of the folder in the directory.
#!/usr/bin/python
import os
path = r"/Users/princessnaana/Desktop/Python_Examples/Naana"
directory_list = os.listdir(path)
for f in directory_list:
src = f
dst = f[f.find('[') + 1:].replace(']','')
replace_name = dst
os.rename (dst) when I print the script the code renames the files as intended however when I run the code it does not change the names of the folder in the directory.
buran write Feb-16-2021, 06:01 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.

That worked!! Thank you so much. You just saved me hours upon hours !!. I appreciate it !!