Skip to content

Real-hackbard/File-SplitterMerger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

File-SplitterMerger:


Compiler      : 10 Seattle 10 1 Berlin 10 2 Tokyo 10 3 Rio
                     10 4 Sydney 11 Alexandria 12 Athens
Components : None
Discription   : File SplitterMerger
Last Update  : 112025
License       : Freeware


A file splitter/merger tool splits large files into smaller parts to facilitate transfer and then reassembles these parts into the original whole. Such tools are useful for files with size limitations or that are difficult to send. You can split files by size or number of parts and adjust the order in which the parts are merged.


FileSplitterMerger


Main Functions:

  • Splitting:

    • Splits a large file into several smaller files.
    • Possible criteria include the number of files or a fixed file size (in bytes, KB, or MB).
    • Offers options for the filename and location.
  • Merging:

    • Rejoins multiple individual parts into a single, original file.
    • Requires that the files to be merged were previously split using the same tool and that they are in the correct order.
    • Can sort the files to be merged by name, date, or size.

Applications

  • Transferring large files: Suitable for splitting very large files (e.g., videos or compressed archives) to send via email or other services that have size limitations.
  • Document management: Special tools are available for PDF files, allowing you to merge multiple PDFs into one or split a large PDF file into individual pages.
  • Format-specific tools: There are also special tools for other file formats, such as vCards, for managing contacts.
  • Important note: To correctly merge a file, all parts created with the same splitter tool must be used and merged in the correct order.

Special Features

  • File Type Independence: General file splitters and mergers can process any file type by simply cutting and joining binary data. However, the resulting parts may not be usable until after merging.

  • Specialized Tools: There are also specialized tools, particularly for PDFs, that offer features such as extracting specific page ranges or adjusting different page sizes during merging.

  • Integrity Checking: Some tools offer automatic integrity checks (e.g., using CRC32 checksums) to ensure that the files are not corrupted during merging.

  • Self-Merging Files: Some splitters can create a small, standalone executable program that can re-merge the parts without the original splitter software.

Add Parameters:

Filename extensions may be considered a type of metadata. They are commonly used to imply information about the way data might be stored in the file. The exact definition, giving the criteria for deciding what part of the file name is its extension, belongs to the rules of the specific file system used..

%f%  : Determination of file names
%n%  : Determining file names without file extensions
%x%  : Determining file extensions such as rar
%p%  : Determination of specific data numbering

As many parameters as you can add to create your own file formats will be determined in this section. The parameters must consist of letters and be delimited by a percent sign. When multiple parameters are involved, the values ​​should be separated by a period.

procedure TForm1.SplitFile(const AFile, AFolder, AFormat: string);
var
  i: Integer;
  sTarget, sFormat: string;
  fsSource, fsTarget: TFileStream;
  iTotal, iChunk: Int64;
  iPart: Integer;
begin
  StatusBar1.SetFocus;
  ProgressBar1.Max := FSplitParts;
  ProgressBar1.Position := 0;
  StatusBar1.Panels[5].Text := 'Splitting wait..';
  sTarget := ExtractFileName(AFile);

sFormat := StringReplace(AFormat, '%f%', sTarget,
                           [rfReplaceAll, rfIgnoreCase]);
  sFormat := StringReplace(sFormat, '%n%', ChangeFileExt(sTarget, ''),
                           [rfReplaceAll, rfIgnoreCase]);
  sFormat := StringReplace(sFormat, '%x%', Copy(ExtractFileExt(sTarget), 2, MaxInt),
                           [rfReplaceAll, rfIgnoreCase]);

  // intigrate here Formats how much you want
  // Example:
  // sFormat := StringReplace(sFormat, '%a%', [Enter the function to be edited here.], ''),
  //                       [rfReplaceAll, rfIgnoreCase]);

  i := Pos('%p:', LowerCase(sFormat));

  if i > 0 then begin 
    Delete(sFormat, i, 3);
    iPart := PosEx('%', sFormat, i);
    i := StrToIntDef(Copy(sFormat, i, iPart - i), 3);
    Delete(sFormat, i, iPart - i + 1);
  end else begin
    sTarget := '%0:.' + IntToStr( Max(3, Length(IntToStr(FSplitParts))) ) + 'd';
    sFormat := StringReplace(sFormat, '%p%', sTarget,
                             [rfReplaceAll, rfIgnoreCase]);
  end;

  sFormat := IncludeTrailingPathDelimiter(AFolder) + sFormat;
  iPart := -1;
  fsSource := TFileStream.Create(AFile, fmOpenRead, fmShareDenyWrite);

  try
    iTotal := fsSource.Size;
    while (iTotal > 0) and not FCancel do begin
      Inc(iPart);
      sTarget := Format(sFormat, [iPart]);
      iChunk := Min(FSplitPartSize, iTotal);
      iTotal := iTotal - iChunk;
      fsTarget := TFileStream.Create(sTarget, fmCreate, fmShareExclusive);

      try
        fsTarget.CopyFrom(fsSource, iChunk);
      finally
        fsTarget.Free;
      end;

      ProgressBar1.StepIt;
      StatusBar1.Panels[3].Text := IntToStr(ProgressBar1.Position);
      Application.ProcessMessages;
    end;
    FDone := not FCancel;
  finally
    fsSource.Free;
    StatusBar1.Panels[5].Text := 'finsh';
  end;
  if FCancel then
    for i := iPart downto 0 do
      DeleteFile(Format(sFormat, [iPart]));
end;

To view the parts, e.g. with WinRAR, a numerical reference must be entered and only the file with the number *.001 can be viewed. This file is stored as an archive file.

About

An example of how to create a file splitter and merger.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages