AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Search for multiple files at once in PC

Ein Thema von danten · begonnen am 31. Dez 2012 · letzter Beitrag vom 2. Jan 2013
 
delnu
(Gast)

n/a Beiträge
 
#4

AW: Search for multiple files at once in PC

  Alt 1. Jan 2013, 14:38
Maybe that this code not exactly feed your needs, but I used it in a big program to check if some of the filetypes are found in the given path.

In a checklistbox I gave some names of filetypes, then I let the program search for it in a given path. If same type matches in this directory, this type is checked in the checklistbox. Instead of using the checkboxes you may use boolean variables that shows, if the searched file/fileytpe was found.
Delphi-Quellcode:
PROCEDURE FindTypes(s:string); // "s" ist the path to search in
VAR
 cnt: integer;
 pfad,
 n: string;
 sr: TSearchRec;

 PROCEDURE SUBB;
 BEGIN
  WITH Form1 DO BEGIN
   n:=AnsiUpperCase(ExtractFileExt(sr.name));
   IF n='.BMP'
   THEN CheckListBox1.checked[ 0]:=TRUE;
   IF n='.GIF'
   THEN CheckListBox1.checked[ 1]:=TRUE;
   IF n='.ICO'
   THEN CheckListBox1.checked[ 2]:=TRUE;
   IF n='.JPG'
   THEN CheckListBox1.checked[ 3]:=TRUE;
   IF n='.PCX'
   THEN CheckListBox1.checked[ 4]:=TRUE;
   IF n='.PNG'
   THEN CheckListBox1.checked[ 5]:=TRUE;
   IF n='.TIF'
   THEN CheckListBox1.checked[ 6]:=TRUE;
   IF n='.WMF'
   THEN CheckListBox1.checked[ 7]:=TRUE;
  END;
 END; { PROCEDURE SUBB }

BEGIN { PROCEDURE FindTypes }
 WITH Form1 DO BEGIN
  FOR cnt:=0 TO CheckListBox1.Items.count-1 DO CheckListBox1.checked[cnt]:=FALSE;
  IF DirectoryExists(s)
  THEN pfad:=s
  ELSE pfad:=ExtractFilePath(s);
  IF pfad[length(pfad)]<>'\THEN pfad:=pfad+'\';
{ showmessage(pfad+^J^M+s);}
  IF autoFind
  THEN BEGIN
   IF FindFirst(pfad+'*.*',faAnyFile,sr)=0
   THEN BEGIN
    WHILE FindNext(sr) = 0
    DO BEGIN
     subb;
    END;
    FindClose(sr);
   END;
  END ELSE BEGIN
   IF FindFirst(pfad+'*.*',faAnyFile,sr)=0
   THEN BEGIN
    WHILE FindNext(sr) = 0
    DO IF AnsiUpperCase(sr.name)=extractFileName(s)
    THEN BEGIN
     subb;
    END;
    FindClose(sr);
   END;
  END;
//SetPicTypes;
 END;
END; { PROCEDURE FindTypes }
edit :
Just I don't know, what the boolean variable "autofind" was. I wrote the program several years ago and just took that bit of the code.

Instead of the checklistbox you can use a listbox with files to search for and then put the results into another listbox with the whole result ( drive + path + filename ) ...

Geändert von delnu ( 1. Jan 2013 um 14:48 Uhr) Grund: edit
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:47 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz