开发者

Generate directory tree from large flat directory list

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 [00000开发者_如何学C0.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? I'd like it to work like this:

$ ls
000001.txt 000002.txt ...
$ mktrie
$ ls
0/ 1/ 2/ ...
$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜