Home > Archive > PHP Language > October 2006 > recursive file search
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
recursive file search
|
|
| Robertico 2006-10-30, 7:03 pm |
| I'am new to php and have a question about a recursive file search.
I'd like to do a recursive search for jpg-files and add the filenames (full
path) to a mysql database.
I appreciate any help !
Regards,
Robertico
| |
|
|
| Jochen Mattes 2006-10-30, 7:03 pm |
| Robertico schrieb:
> I'am new to php and have a question about a recursive file search.
> I'd like to do a recursive search for jpg-files and add the filenames (full
> path) to a mysql database.
> I appreciate any help !
>
> Regards,
>
> Robertico
>
>
Hi Robertico,
it's quite easy *g*
I'll give you the keywords:
loop, array, dir (http://ch2.php.net/manual/en/class.dir.php),
is_dir() (http://ch2.php.net/is_dir)
Try it out!
If you need more support just send me an email (jmattes {at} student
{dot} ethz {dot} ch)
But try to solve it yourself before sending me an email.
Greets Jochen
| |
| pangea33 2006-10-30, 7:03 pm |
|
Robertico wrote:
> I'am new to php and have a question about a recursive file search.
> I'd like to do a recursive search for jpg-files and add the filenames (full
> path) to a mysql database.
> I appreciate any help !
>
> Regards,
>
> Robertico
I went ahead and wrote a couple different scripts to do this because I
found it an interesting topic. Yes recursive php directory searches can
do what you want, but they're too resource intensive when you're just
looking for filenames. You can accomplish this very fast using the
"find" shell command, as long as you can run "shell_exec()" in php.
http://www.ss64.com/bash/find.html
**************
SCRIPT OUTPUT:
There were a total of 889 jpg files found
Executed file search in 0.073278903961182 seconds
Generated SQL INSERT script with mysql_escape_string in
0.19165515899658 seconds
Executed search and generated SQL INSERT script with
mysql_escape_string in 0.26493406295776 seconds
**************
The protocol around here seems to be only offering *hints* at first, so
I don't want to make anyone mad. I'm willing to share if you get
totally stumped though.
|
|
|
|
|