写一个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>"文件目录中的文件数组"</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教程有兴趣的朋友有所帮助。