Rename Sub Folders in A Directory With Python
Here's a little bit of code that renames sub folders in a directory with python.
import os
import os.path
for (dirpath, dirnames, filenames) in os.walk(r'O:\!2016\your folder path here):
for idx in range(len(dirnames)):
print(dirnames[idx])
newname = dirnames[idx].split(' ')[0].upper() + " " + dirnames[idx].split(' ')[1].upper()
os.rename(os.path.join(dirpath, dirnames[idx]), os.path.join(dirpath, newname))
dirnames[idx] = newname
import os
import os.path
for (dirpath, dirnames, filenames) in os.walk(r'O:\!2016\your folder path here):
for idx in range(len(dirnames)):
print(dirnames[idx])
newname = dirnames[idx].split(' ')[0].upper() + " " + dirnames[idx].split(' ')[1].upper()
os.rename(os.path.join(dirpath, dirnames[idx]), os.path.join(dirpath, newname))
dirnames[idx] = newname