I am new to python but am keen to learn/optimise some basic functions which later will come in very handy for larger dataset handling. I have a series of folders where there is a list of parent folders all with the same stem but different number, and sub-folders which I want to name based off each individual parent folder.
There are parent folders for example 'Apple_1, Apple_2, Apple_3' and sub-folders for example 'red, green, pink'. I want to modify the sub-folder names to 'Apple_1 Colour_1, Apple_1 Colour_2, Apple_1 Colour_3' if this makes sense but apply a batch script to all of the parent folders within a directory.
Below is my script for applying this naming process to one single parent folder and it's sub-folders which works but how do I batch apply this to a whole series (N=50) parent folders to perform iteratively rather than individually having to run it on each parent folder?
folder path = r'D:/Home/Fruit/Apples/ParentFolder'
fileNumber = 1
for filename in os.listdir(folderPath):
os.rename(folderPath + '//' + filename, folderPath + "//" +
"Parentfolder_Colour_" + str(fileNumber))
fileNumber +=1
Grateful in advance for anyone's advice. Thanks