?
Solved

Unique pattern mask for FindFirst

Posted on 1999-10-26
3
Medium Priority
?
476 Views
Last Modified: 2010-04-04
Hi

This might be a silly question, but when using FindFirst and FindNext I need to have a unique type of pattern mask.  

The ap I am writing has to search through multiple directories searching for files which do not contain a numeric character (0 - 9) as the second character in the filename.

90% of the files will look like A100363_.tif or T100363_.tif.  They are files which have been processed, but the rest of the files are named with people's names.  Nearly all the names are in the middle of the Dir listing except for those after and including the letter T.

Is there a way to find just the files named after people?  I do not want to copy them to another folder to do it.
0
Comment
Question by:jdthedj
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
victor_christov earned 400 total points
ID: 2161542
Try this


Function MyFiles( Path : String ; Attr : Word) : TStringList ;
Var
  FList : TStringList ;
  SRec  : TSearchRec;
begin
  FList := TStringList.Create ;
  FList.Clear          ;
  FList.Sorted := True ;    { this line is optionally }


  if FindFirst(Path,Attr,SRec) = 0  then begin
     if not (SRec.Name[2] in ['0'..'9']) then
        FList.Add(SRec.Name) ;
     while FindNext(SRec) = 0 do
       if SRec.Name[2] in ['0'..'9'] then
          FList.Add(SRec.Name) ;
  end;

  MyFiles := FList ;

  FList.Free ;
end;


and I am sure that this function will return list of files, that not contain a numeric character as the second character in the filename. You can use Path and Attr as an additonal constrains.
0
 
LVL 1

Expert Comment

by:victor_christov
ID: 2161564
I made a mistake in condition for FindNext. The correct line is :

While FindNext(sRec) = 0 do
  if not (SRec.Name[2] in ['0'..'9']) then
   FList.Add(SRec.Name) ;
 
0
 
LVL 3

Author Comment

by:jdthedj
ID: 2163580
Hi Victor - thanks for the reply.  That is an excellent way to do it!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question