Вот набросал пример Код
program Project2;
uses
windows;
function GetExtension(s: string): string;
var
i: integer;
begin
result:='';
for i:=Length(s) downto 0 do
if s[i] = '.' then
begin
result:=copy(s, i, Length(s));
exit;
end;
end;
function FindFile(path, ext: string): boolean;
var
a: Cardinal;
fa: _WIN32_FIND_DATAA;
begin
a:=FindFirstFile(PansiChar(path+PChar('\*.*')),fa);
SetConsoleTitle(PChar(path));
while FindNextFile(a,fa) do
begin
if ((fa.cFileName<> '..') and (fa.cFileName<> PChar('.'))) then
begin
if fa.dwFileAttributes = $00000010 then FindFile(path+'\'+fa.cFileName, ext)
else if pos(CharLower(PansiChar(GetExtension(fa.cFileName)+#0)), CharLower(PansiChar(ext+#0)))<>0
then writeln(path+'\'+fa.cFileName);
end;
end;
FindClose(a);
end;
var
C: char;
begin
AllocConsole();
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
for C:= 'A' to 'Z' do
FindFile(C+':', '.res.txt');
readln;
end.
Рекурсивно ищет по всем дискам файлы с расширениями .res и .txt