Restructioring folders using a shell script

view story

http://unix.stackexchange.com – I have the following type of folder structure containing thousands of folders. The folder names are as such with different names etc .test .test.subfolder .test.subfolder.subsubfolder .folder .folder.one .folder.two .folder.one.one What I need to achieve is the following i want the folders to be renamed eg. from .test to test and then move .test.subfolder so that the folder .subfolder is within the folder test without the . , and then .test.subfolder.subsubfolder so that subfolder is within folder test and subsubfolder is within test->subfolder This needs to be recursive since there ar (HowTos)