program lc; {$APPTYPE CONSOLE} uses System, Windows, SysUtils, Classes, Masks; procedure GetFileList(basedir : string; const filemask : string; includesubdir : boolean; const strlist : tstringlist); var x:TSearchRec; v_basedir : string; v_attr : integer; v_filemask : string; v_currfilemask : string; v_pos : integer; begin if basedir <>'' then v_basedir := IncludeTrailingBackslash(basedir) else v_basedir := '.\'; v_Attr := faAnyFile; if includesubdir = false then v_Attr := v_Attr - faDirectory; if FindFirst(v_basedir+'*.*',v_Attr,x)=0 then repeat if ((x.Attr and fadirectory)<>0) then begin if (x.Name<>'.') and (x.Name<>'..') then GetFileList(v_basedir+x.name,filemask,includesubdir,strlist); end else begin v_filemask := filemask; repeat v_pos := pos(';',v_filemask); if v_pos>0 then begin v_currfilemask := copy(v_filemask,1,v_pos-1); v_filemask := copy(v_filemask, v_pos+1,2000); end else begin v_currfilemask := v_filemask; v_filemask := ''; end; if MatchesMask(x.name, v_currfilemask) then strlist.add(v_basedir+x.name); until v_filemask = ''; end; until FindNext(x)<>0; FindClose(x); end; var i : integer; subd,hlp : boolean; fm,fn : string; fl,ff : tstringlist; tl : integer; begin subd := false; hlp := false; for i := 1 to ParamCount do begin if (paramstr(i)='/?') then begin hlp := true; end else if lowercase(paramstr(i))='/s' then begin subd := true; end else begin hlp := fm<>''; fm := paramstr(i); end; end; if hlp then begin writeln('lc.exe [/s] filemask[;filemask..]'); writeln(' /s = include subdirectories'); writeln(' '); writeln('example : lc.exe /s *.pas;*.dpr'); exit; end; fl := tstringlist.create; ff := tstringlist.create; GetFileList(GetCurrentDir, fm, subd, fl); tl := 0; for i := 0 to fl.Count-1 do begin fn := fl.strings[i]; ff.LoadFromFile(fn); writeln(format('%10d',[ff.count]) + ' '+fn); inc(tl,ff.count); end; writeln('=========='); writeln(format('%10d',[tl]) + ' in total'); fl.free; ff.free; end.