I'd like to get a list of folders that don't contain certain files. I'm using this to list directories & files:
$path = "media";
$dir_handle = @opendir($path) or die("Unable to open $path");
function list_dir($dir_handle,$path) {
while (false !== ($file = readdir($dir_handle))) {
$exclude = array(".","..","_player_thumbs","Thumbs.db");
$dir =$path.'/'.$file;
if(is_dir($dir) && !in_array($file, $exclude)) {
$handle = @opendir($dir) or die("undable to open file $file");
echo "\n$file<br />\n";
list_dir($handle, $dir);
}elseif(preg_match('/(mp3|mp4|flv|swf)/', $file) && !in_array($file, $exclude)) {
echo " $file<br />\n";
}
}
closedir($dir_handle);
}
list_dir($dir_handle,$path);
This returns this:
All
both.swf
countdown1.flv
countdown2.flv
countdown3.flv
countdown4.flv
Lady in Red.mp3
load.mp4
load_1.mp4
Mean Ol' Girl.mp3
Story of My Life.mp3
Summer's Snow.mp3
Table for Two.mp3
test_mp4_1.mp4
Audio
audio.swf
Lady in Red.mp3
Mean Ol' Girl.mp3
Story of My Life.mp3
Summer's Snow.mp3
Table for Two.mp3
One Song
singleaudio.swf
Story of My Life.mp3
One Video
singlevideo.swf
test_mp4_1.mp4
Video
countdown1.flv
countdown2.flv
countdown3.flv
countdown4.flv
load.mp4
load_1.mp4
StatelyOneSong.swf
test_mp4_1.mp4
video.swf
What I want is to leave out the directories with the "singleaudio.swf" & "singlevideo.swf" to get this:
All
both.swf
countdown1.flv
countdown2.flv
countdown3.flv
countdown4.flv
Lady in Red.mp3
load.mp4
load_1.mp4
Mean Ol' Girl.mp3
Story of My Life.mp3
Summer's Snow.mp3
Table for Two.mp3
test_mp4_1.mp4
Audio
audio.swf
Lady in Red.mp3
Mean Ol' Girl.mp3
Story of My Life.mp3
Summer's Snow.mp3
Table for Two.mp3
Video
countdown1.flv
countdown2.flv
countdown3.flv
countdown4.flv
load.mp4
load_1.mp4
StatelyOneSong.swf
test_mp4_1.mp4
video.swf