dongshang1979 2011-01-26 23:43
浏览 28
已采纳

如何将500k图像从单个目录分隔到多个?

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 with a sample code so I can modify it??

Thanks in advance

  • 写回答

1条回答 默认 最新

  • doutuo7609 2011-01-26 23:52
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程