views:

125

answers:

1

Let's say I have one directory in my filesystem, which has a number of subdirectories and files. The number of subdirectories and files in this directory runs to many tens of thousands. You'll be familiar with the significant delay you'll get in attempting to view the contents of this directory, even in a terminal.

I've seen this solution in a fair number of places: sorting that top-level list of contents into a trie-style directory structure. So, for example, if the original list was [000000.txt ... 999999.txt], then to get to the file 012345.txt, I would visit, say, ./0/1/2/3/4/012345.txt .

What I've been unable to find is a short and sweet script to generate this kind of structure. Does something exist or must I write my own?

A: 

If I got your problem right I have two Python scripts for this:

http://www.hietavirta.net/blog/item/2009/12/some-file-organizing-with-python

Petteri Hietavirta