keeping subdirectory files in order
Posted on 2003-02-24
I am traversing a directory with all its subdirectories and I need to keep all the filenames grouped by directories, starting with the root, then going depth-first. This does not automatically happen because some filenames in the root directory, for example, may alphabetically precede the subdirectories. In order to fix this, I was thinking of adding a prefix to each file, so if it's in the root, its prefix would be 001, the next folder would be 002, etc. So basically, I want it to look something like this: "001C:\Perl\Test\Image.tif"
Any ideas on how to add this prefix (which I will later remove) or another way to keep the directories in order?