program filestolowercase;

(*
uses
  DOS,
  sysutils;
var
  Dir : TSearchRec;
  s1, s2: string;
  res: integer;

begin


  FindFirst('*.*',archive,Dir);
  res:= DOS.DosError;
  while (res=0) do
  begin
    s1:= Dir.Name;
    s2:= lowercase( s1 );
    if ( s1 <> s2 ) then
    begin
        writeln( s1 );
    end;
    FindNext(Dir);
    res:= DOS.DosError;
    writeln( res, s1 );
    if ( s1 = '' ) then res:= -1;
  end;
  FindClose(Dir);
  writeln( 'fin.');
end.
*)

{ Program to demonstrate the
  OpenDir,ReadDir, SeekDir and TellDir functions. }

Uses BaseUnix;

procedure procesarArchi( archi: string );
var
  s: string;
begin
  s:= lowercase( archi );
  if s <> archi then
  begin
    writeln( archi, ' -> ', s );
    fprename( archi, s );
  end;
end;



Var TheDir : PDir;
    ADirent : PDirent;
    aname: string;
begin
  TheDir:=fpOpenDir('./.');
  Repeat
    ADirent:=fpReadDir (TheDir^);
    If ADirent<>Nil then
    begin
      aname:= StrPas( @ADirent^.d_name[0] );
      case ADirent^.d_type of
//        4: procesarDir( aname );
        8: procesarArchi( aname );
      end;
    end;
  Until ADirent=Nil;
  fpCloseDir (TheDir^);
end.

