Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Script I need :) please help!!

Status
Not open for further replies.

yuflesh

Programmer
May 4, 2001
4
0
0
CA
Hello people,
I got a question for you.Im making somewhat of a photo album. And pictures are stored in different folders depending on the event. Anyhow, my question here is, where can I get a free search script, that will lookup the picture, event, etc, etc. After the files are put there by the user, there is a script (also perl :) ) that automatically creates thumbnails. So basically I would do the search for a file or event (folder). All the searches Ive seen so far, have some kind of flat database, that needs to be updated from time to time. Is there a way that can be done automatically. I will have quite a few people that will upload pics, every so often, and I don't want to go there ever 2 hours and update the search database file. And also I just want it to be able to search root directory and the tree below it (basically just directories created by the users).

Can anybody help, Ive been working on this thing for a while now, and Im getting tired, not to mention my brain turning into jello, so if somebody can enlighten me, please do so.

Thank you

Marko
 
here is a simple search script. u can modify it not to search inside the files but work with the names only. change the extention to jpg or gif. u can also save the list to a file so the next time it will run it will check only for new images. now for the thumbs if u can't write your own script you can integrade it with
#!/bin/perl

#### Environment Variables
$word = "what to search for"; ### WARNING: CASE SENSITIVE
$doc_root = "/home/stefanos/enterprise-3.63/web/docs";
$find_path = "/bin/find";
$ext = "html"; # Extention to searchfor

#### Commands
$find_command = "$find_path $doc_root -name *.$ext |";


##### Get a list of all the files in the document root
open(FIND, $find_command) or die "Cannot Search ...\n\n";
@allfileslist = <FIND>;
close(FIND);

##### Open each file individually and search for keywords
foreach $file (@allfileslist) {
open(FILE,&quot;$file&quot;);
@lines = <FILE>;
close(FILE);
foreach $text (@lines) {

if ($text =~ $word) {
$file =~ s/$doc_root//g;
print &quot;$file&quot;;
}
}
}



alexandros@onebox.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top