before I go down a wrong path, thought I'd check in case there was a blindingly easy way to do my thing..
I'm using the proc at bottom to find all the files contained in a directory.
Once I have that, I want to look through the list and find all those that have an extension matching a lookup list.
Those that do, I want to add to a listbox.items set, and at the same index in another listbox.items set I want to add that same file name, with extra text before the extension, depending on which extension it is.
Those files in the search list that do not match any of the lookup extensions are to be put into a 3rd list.
As so:
lookup table:
abc fred
efg john
ghi bob
Search.list New1.list new2.list new3.list
file1.abc file1.abc file1 fred.abc file3.tar
file2.efg file2.efg file2 john.efg file4.uue
file3.tar file5.ghi file5 bob.ghi
file4.uue file6.abc file6 fred.abc
file5.ghi
file6.abc
Are there built in functions I can use for this seemingly simple task?
Steve
Search proc:
//this proc finds all files in a directory passed to it
procedure ListFileDir(Path: String; FileList: TStrings);
var
SR: TSearchRec;
begin
if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr And faDirectory) <> faDirectory then
begin
FileList.Add(SR.Name);
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;
I'm using the proc at bottom to find all the files contained in a directory.
Once I have that, I want to look through the list and find all those that have an extension matching a lookup list.
Those that do, I want to add to a listbox.items set, and at the same index in another listbox.items set I want to add that same file name, with extra text before the extension, depending on which extension it is.
Those files in the search list that do not match any of the lookup extensions are to be put into a 3rd list.
As so:
lookup table:
abc fred
efg john
ghi bob
Search.list New1.list new2.list new3.list
file1.abc file1.abc file1 fred.abc file3.tar
file2.efg file2.efg file2 john.efg file4.uue
file3.tar file5.ghi file5 bob.ghi
file4.uue file6.abc file6 fred.abc
file5.ghi
file6.abc
Are there built in functions I can use for this seemingly simple task?
Steve
Search proc:
//this proc finds all files in a directory passed to it
procedure ListFileDir(Path: String; FileList: TStrings);
var
SR: TSearchRec;
begin
if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr And faDirectory) <> faDirectory then
begin
FileList.Add(SR.Name);
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;