M
M
maxxiixx2014-05-21 21:20:51
Delphi
maxxiixx, 2014-05-21 21:20:51

How to merge 541 files sequentially into one

How to merge files sequentially into one.
One to the end of the other, etc.
There are 541 files in total, 5 MB each.
So that the memory does not fly out.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
maxxiixx, 2014-05-21
@maxxiixx

var
i:integer;
my_stream:TMemoryStream;
my_filestrem:TFileStream;
//.........................................

  my_filestrem:= TFileStream.Create(ExtractFilePath(Application.ExeName)+Edit3.Text+'\file.mp4', fmCreate);

  for i := 0 to Memo2.Lines.Count - 1 do
  begin

    my_stream:=TMemoryStream.Create;
    try
      IdHTTP1.Get(Edit5.Text+Memo2.Lines.Strings[i], my_stream);
      my_stream.Position := 0;
      my_filestrem.CopyFrom(my_stream,my_stream.Size);
      //my_stream.SaveToFile(ExtractFilePath(Application.ExeName)+Edit3.Text+'\'+Memo2.Lines.Strings[i]);
    except
    end;
    my_stream.Free;

    Application.ProcessMessages;
  end;
  my_filestrem.Free;

P
Pavel Shvedov, 2014-05-21
@mmmaaak

c94279bc5b474a35b9627211160504b3.jpg

Z
zed, 2014-05-21
@zedxxx

Use TFileStream:

var
    out: TFileStream;
    in: TMemoryStream;
    i: Integer;
begin
    in := TMemoryStream.Create;
    out := TFileStream.Create(...);    
    try
        for i := 0 to files_count - 1 do begin            
            in.Clear;
            in.LoadFromFile(....);            
            out.WriteBuffer(in.Memory^, in.Size);
        end;
    finally
        in.Free;
        out.Free;
    end;
end;

M
m-haritonov, 2014-05-21
@m-haritonov

Read a small portion of data from each file and write it to the end of the new file.

A
Alexander, 2014-05-21
@yakupovak

cat * >> new_file
Isn't this a solution or, as the author says, eats up memory?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question