I do have 500k images in one directory. Name of these images are stored in MySQL database. I want to divide this 500k images into 10k each directories. like 10k images in img01, another 10k images in img02,..etc. How can I do this with a PHP program?? does any one can help me开发者_如何学JAVA with a sample code so I can modify it??
Thanks in advance
I will just show a pseudo-code approach, and if you are still stuck you can show what you tried and where you are stuck.
Select all images
Loop through the result
if cntr mod 10k == 0 then
make new directory
else
use last directory
Move the file to the new directory.
end loop
Then loop through each directory, updating the location in your database.
Now, another approach is to read everything in, then do the update in the loop, depending on memory availability.
精彩评论