I implemented this in two parts. The first part created the required directory structure:
workPath = "/tmp/test/"
for a in range (0, 16):
for b in range (0, 16):
for c in range (0, 16):
The next part was to move files to the corresponding directories. This was also quite straightforward but I had problem with os.rename and I had to replace it with shutil.move. The original script worked fine on my home computer but the development server had the source and destination directories in different filesystems. Here is the final version:
sourceDir = "/tmp/files/"
destDir = "/tmp/test/"
filenames = os.listdir(sourceDir)
for filename in filenames:
sourceFile = sourceDir+filename
destFile = destDir+filename+"/"+filename+"/"+filename+"/"+filename
These did not take too long to make and most likely someone who remembers Python libraries better would have done it in a fraction of time.