寫一個php檔案放到你想要批次處理的檔案目錄下,執行檔案即可完成
注意:確認你的檔案名稱是不是時間戳,還有文件裡的php文件,要加上判斷!不要誤刪了!
<code> set_time_limit(<span>0</span>); <span>//忽略php.ini设置的脚本运行时间限制 </span><span>$q_array</span> = my_dir(<span>'./'</span>); <span>$q_array</span> = str_replace(<span>'.//'</span>,<span>''</span>,<span>$q_array</span>); <span>$a</span> = explode(<span>","</span>,<span>$q_array</span>); <span>echo</span><span>"文件目录中的文件数组</br>"</span>; var_dump(<span>$a</span>); forEd(<span>$a</span>);<span>//修改文件名</span><span>//循环建立新的文件根据时间戳移动文件到指定文件夹修改名称</span><span><span>function</span><span>forEd</span><span>(<span>$arr</span>)</span>{</span><span>$dir</span> = <span>array</span>(); <span>foreach</span>(<span>$arr</span><span>as</span><span>$v</span>){ <span>$dir</span>[] = substr(<span>$v</span>,<span>0</span>,<span>6</span>); } <span>foreach</span>(<span>$arr</span><span>as</span><span>$v</span>){ <span>$newDir</span> = substr(<span>$v</span>,<span>0</span>,<span>6</span>); <span>foreach</span>(<span>$dir</span><span>as</span><span>$v2</span>){ <span>if</span>(<span>$v2</span> == <span>$newDir</span>){ mk_dir(<span>$newDir</span>); @!copy(<span>$v</span>,<span>$newDir</span>.<span>'/'</span>.substr(<span>$v</span>,<span>6</span>)); } } } <span>return</span><span>true</span>; }</code>
以上就介紹了 php循環建立新的檔案根據檔案名稱移動檔案到指定資料夾修改檔案名稱,包括了方面的內容,希望對PHP教學有興趣的朋友有所幫助。