I have nearly 1 million photos auto-incrememted starting at "1".
So, I have the following:
1.jpg
2.jpg
3.jpg
4.jpg
5.jpg
....
1000000.jpg
Currently, I have all of these files in a single Ext4 linux directory.
As you can imagine, the filesystem is crazy slow.
Using PHP, how can I create an algorithm that divides up my images into a directory structure so that each directly has significantly less objects per directory.
For example:
1000/1.jpg
1000/2.jpg
1000/3.jpg
...
1000/999.jpg
1000/1000.jpg
2000/1001.jpg
2000/1002.jpg
2000/1003.jpg
2000/1999.jpg
How would I divide/modulus/implode/shift the image name (id) into a file structure like such above?
UPDATE:
Basically, I want to create a PHP function that does the following.
- Only accept positive integers, not including 0.
- For values 1-999, return 0
- For values 1000-1999, return 1000
- For values 10,000-10,999, return 10000
- For values 25,000-25,999, return 25000