开发者

How do I seperate 500k images from single directory to multiple?

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜