I have a directory in a filesystem (specifically linux/ext3 but the intent of the question is to be more generic) that potentially has a number of subdirectories and files at each level of the tree.
I would like to essentially flatten this kind of structure and place all of the files in the topmost directory in the tree and remove all remaining (now empty) subdirectories.
Aside: At some point I also want to add in the functionality to handle potential namespace collisions, but that seems much more simple.
As is almost always the case TIMTOWTDI, but I am seeking some wisdom in better practices from anyone who has done similar operations before. It seems that system, exec, etc. are wasteful as far as resources are concerned. Potentially I could write some recursive readdir-based function and use that to move any nodes of type file to the parent. Additionally there is a case to be made for using something like File::Find to make this happen as well.
Please share what you know about a great way to address this problem.
In reply to Flattening a directory tree in a filesystem by steve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |