System Delphi

Title: A missing one: ChangeFileName.
Question: I was not able to find that... so I made it.
Answer:
Function ChangeFileName( FileName, NewName : String ) : String;
Var
IdX : Integer;
IdY : Integer;
Begin
FileName := Trim( FileName );
If ( Length( FileName ) 0 ) Then Begin
For IdX := Length( FileName ) DownTo 1 Do
If ( FileName[ IdX ] = '.' ) Then
Break;
For IdY := Length( FileName ) DownTo 1 Do
If ( FileName[ IdY ] = '\' ) Then
Break;
If ( IdX IdY ) Then
Result := Copy( FileName, 1, IdY ) + NewName + Copy( FileName, IdX, MaxInt )
Else
Result := '';
End Else
Result := '';
End;