Ver Mensaje Individual
  #1  
Antiguo 03-10-2011
Paulao Paulao is offline
Miembro
 
Registrado: sep 2003
Ubicación: Rua D 31 Casa 1 - Inhoaíba - Rio de Janeiro - RJ - Brasil
Posts: 637
Reputación: 23
Paulao Va por buen camino
No consigo renombrar un archivo

Mira, no estoy conseguindo renombrar un archivo con RenameFile en una busca con SearchRec. Abajo mi rutina que deberia renombrar mis archivos.
Código Delphi [-]
procedure TFileFinder.Start;
  procedure PathFound(const Path: string);
  var
    Dir,texto,txt1,txt2,txtfinal,ext: string;
    Mask: string;
    SR: TSearchRec;
  begin

    Dir := IncludeTrailingPathDelimiter(Path);
    if not AceitarDirectory(Dir) then
      Exit;

    // Procura os arquivos
    Mask := Dir + '*.*';
    if Active and (FindFirst(Mask, faAnyFile - faDirectory, SR) = 0) then
      try
        //fNextDir := false;
        inc(cont);
        texto := '-'+StrZero(cont,4);
        repeat
          txt1 := SR.Name;
          Insert(texto,SR.Name,21);
          txt2 := SR.Name;
          RenameFile(txt1,txt2);
        until (FindNext(SR) <> 0) or (not Active);// or fNextDir;
      finally
        FindClose(SR);
      end;

    // Percorre a arvore de diretórios
    Mask := Dir + '*.*';
    OnDir := Mask;
    if Active and Recursive and (FindFirst(Mask, faDirectory, SR) = 0) then
      try
        repeat
          if (SR.Name <> '.') and (SR.Name <> '..') then
            PathFound(Dir + SR.Name);
        until (FindNext(SR) <> 0) or (not Active);
      finally
        FindClose(SR);
      end;
  end;
Responder Con Cita