omiting the Mac "._" metafiles while looping...
Posted: Tue Jul 17, 2007 3:47 pm
Hey all,
I have what should be a pretty easy question. I'm building a PHP page to convert image types on the backend, but my testing has run me into a few problems... The biggest one is this: My entire office uses Macintosh computers (with like 3 exceptions...), and so almost all of our assets are stored on our servers with the "._" prefix that names them as a Macintosh metafile.
Now, sometimes this isn't really an issue, but it seems to be when I try to loop through a directory to grab the files, as it also grabs and returns those stoopid metafiles as well, which I don't want at all! It's not just this, but I have been able to bootleg my way around it with comparison values, but I am really getting tired of having to invent new ways to get around these files, and deleting them isn't much of an option, as any time they are accessed by anyone on the network, they'll most likely just get new ones assigned to them...
So my question is this: With this snippet of code, anyone know how I can exclude those files from the loop?
Thanks for any help in advance!
Stephen
I have what should be a pretty easy question. I'm building a PHP page to convert image types on the backend, but my testing has run me into a few problems... The biggest one is this: My entire office uses Macintosh computers (with like 3 exceptions...), and so almost all of our assets are stored on our servers with the "._" prefix that names them as a Macintosh metafile.
Now, sometimes this isn't really an issue, but it seems to be when I try to loop through a directory to grab the files, as it also grabs and returns those stoopid metafiles as well, which I don't want at all! It's not just this, but I have been able to bootleg my way around it with comparison values, but I am really getting tired of having to invent new ways to get around these files, and deleting them isn't much of an option, as any time they are accessed by anyone on the network, they'll most likely just get new ones assigned to them...
So my question is this: With this snippet of code, anyone know how I can exclude those files from the loop?
Code: Select all
<?php
include("class.imageconverter.php");
$dir = "GIFs/";
$handle=opendir($dir); //current directory, can be changed
$counter = 0;
while ($file = readdir($handle)) {
//check file type for images
$the_type = strrchr($file, ".");
$is_picture = eregi("jpg|gif|bmp|png",$the_type); //adjust for other image types
if ($file != "." and $file != ".." and $is_picture) {
$mypics[$counter] = "GIFs/".$file;
//$size[$counter] = getimagesize($mypics[$counter]);
//print $mypics[$counter];
$img = new ImageConverter($mypics[$counter],'jpg');
$counter++;
}
echo $mypics[$counter];
}
print $counter;
closedir($handle);
?>Stephen