I'm struggling to find any information on looping through all subfolders within a folder and renaming them using PHP. I am renaming them so that I do not reach any limits on numbers of subfolders.
At the moment my user folder structure is as follows :
images/logos/1216/logo.jpg
images/logos/11437/logo.jpg
images/logos/234438/logo.jpg
So I want to loop through all folders within the 'logos' and rename them as follows :
images/users/1/1216/logos/logo.jpg
images/users/11/11437/logos/logo.jpg
images/users/234/234438/logos/logo.jpg
To calculate the new subfolder name, i'm going to take the existing user id (i.e. 11437 and divide by 1000).
The actual issue is how, do I loop through all the subfolders and what is the best way to rename the folder structure.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…