Thousands of images, how should I organize the directory structure? (linux)

前端 未结 6 1081
一向
一向 2020-12-07 23:31

I am getting thousands of pictures uploaded by thousands of users on my Linux server, which is hosted by 1and1.com (I believe they use CentOS, but am unsure of the version).

6条回答
  •  感情败类
    2020-12-08 00:16

    What I used for another requirement but which can fit your needs is to use a simple convention.

    Increment by 1 and get the length of the new number, and then prefix with this number.

    For example:

    Assume 'a' is a var which is set with the last id.

    a = 564;
    ++a;
    prefix = length(a);
    id = prefix + a; // 3565
    

    Then, you can use a timestamp for the directory, using this convention:

    20092305 (yyyymmdd)
    

    Then you can explode your path like this:

    2009/23/05/3565.jpg
    

    (or more)

    It's interesting because you can keep a sort order by date, and by number at the same time (sometimes useful) And you can still decompose your path in more directories

提交回复
热议问题