|
Posted by J. Frank Parnell on 08/01/07 19:31
On Wed, 1 Aug 2007 12:55:46 +0100, Toby A Inkster
<usenet200707@tobyinkster.co.uk> wrote:
>J. Frank Parnell wrote:
>
>> I got this directory tree listing function somewhere, it works great,
>> but I want it to only list directories that do have one or more .jpgs
>> inside.
>
>It's a bit of a cheat, but...
>
><?php
>function find_dirs_with_jpegs ($path)
>{
> $path = addslashes($path);
> $find = "find '{$path}' -iregex '.*\\.jpe?g' -printf '%h\\n'";
> $dirs = explode("\n", `$find | sort -u`);
> array_pop($dirs);
> return $dirs;
>}
>?>
Since i have php4, i tried this (thanks anyway Michael Fesser).
Works great, thanks! Could you explain 'bit of a cheat'? Am I going to get
caught? :)
I'm using this on a dir with about 4500 dirs, about 3300 of which have jpgs(the
rest are mostly ancestors of the jpg dirs), according to this func (which
matches what i came up with using my getDirlistAndForeachLookingForJpgs().)
find_dirs_with_jpegs () seems faster, though i didnt scientifically test it.
Navigation:
[Reply to this message]
|