我有一个包含一些图片pic1.jpg, pic2.jpg, pic3.jpg, frame2.jpg. round.jpg
的文件夹。我的问题是如何只将pic*.jpg
图像移动到新文件夹而不使用php添加其他图像frame*.jpg
和round.jpg
答案 0 :(得分:1)
foreach(glob("/old/pic*.jpg") as $file)
{
rename($file, "/new/".basename($file));
}
答案 1 :(得分:0)
// search for all the pathnames matching pattern
foreach(glob("/myfolder/pic*.jpg") as $file)
{
// check if newfolder exists, if not create it
if(!is_dir('/newfolder') && !file_exists('/newfolder')) {
mkdir('/newfolder', 0755);
}
// new file path
$newfile = '/newfolder/'.basename($file);
// copy file to new location
copy($file, $newfile);
}