Write a php file and put it in the file directory you want to batch process, and run the file to complete
Note: Make sure your file name is a timestamp, and the php file in the file must be judged! Don’t delete it by mistake!
<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>
The above has introduced how PHP loops to create new files, move files to specified folders and modify file names according to file names, including the following aspects. I hope it will be helpful to friends who are interested in PHP tutorials.