Skip to content
GSplit

Command line: GSplit and gsplitc

Advanced reference

For scripts, servers and scheduled jobs.

Two programs split from a command line, and both run the same code as the window:

ProgramWhat it is
gsplitc (gsplitc.exe on Windows)The console. Windows and Linux, no window, no WebView2. Use it in scripts, servers and CI.
GSplit.exeThe window. With a command-line switch it never opens a window and behaves like gsplitc; without one it opens on the files you name.

In a script, prefer gsplitc. GSplit.exe is a graphical program: the prompt returns at once, so use start /wait (cmd) or Start-Process -Wait (PowerShell) to get its exit code.

To join pieces from a script, see Command line: gunitec. To keep settings in a file, see Project files and batch lists.

gsplitc <source> [-go] [options]
gsplitc - [options]
gsplitc <source> -c <project.gsc> [options]
gsplitc -c <project.gsc> [options]
gsplitc no -b[-i][-t] <batch.txt> [options]
gsplitc --help
gsplitc --version
FormWhat it does
gsplitc <source> [-go] [options]Splits the source. Without options: 1 MB pieces named disk{num}.gsd in the source's folder.
gsplitc - [options]Reads the source from standard input.
gsplitc <source> -c <project.gsc>Takes the settings from a GSplit 4 project file.
gsplitc -c <project.gsc>Takes the source and the destination from the project file.
gsplitc no -b <batch.txt>Reads a GSplit 3 batch file.
--help, --versionPrint the banner and the usage, or the banner and the version. A normal run prints no banner.

Options come after the source, in any order, and override the project file or the batch file. Put a path that contains spaces between double quotes.

GSplit.exe with no switch opens its window. The files on the command line decide what the window shows first. The Explorer context menu starts GSplit this way.

CommandResult
GSplit.exe <file> [<file> ...]The Source file page shows the file. Several files fill the Split multiple files list and open its dialog.
GSplit.exe --unite <piece>The Unite page opens with that piece inspected. Any piece of the set works. Other paths on the line are ignored.
GSplit.exe --open <file.gsc>The project file is loaded, as File > Open project does. One .gsc as the only path does the same.
GSplit.exe --file-list <list.txt>As the first form, with the paths read from a text file.
  • A list file is UTF-8 (a byte order mark is allowed), one path per line, empty lines skipped. The paths of the list come after the paths on the line.
  • GSplit deletes a list file after reading it only when it sits in the temporary folder and its name starts with gsplit-shell-. These are the files of the Explorer extension. Any other list file is left alone.
  • Relative paths are taken from the current folder. Folders and paths that are not an existing file are ignored. If nothing is left, the window opens as without arguments.
  • With one file, the default project of Options is loaded first, then the file becomes the source.
  • --unite and --file-list are window switches. They never start a command-line run. Any switch of the sections below does, and then no window is created.

These switches work as in GSplit 3, written separately or joined (-b-i-t).

SwitchMeaning
-goSplit now. Alone, it uses the defaults. With -c, it uses the project's settings.
-c <file>Load the project file given next. It must be a GSplit 4 .gsc.
-b <file>Read the batch file given next. Without -i, the batch is only checked: every file is prepared and nothing is written.
-iExecute the batch.
-tAccepted, no effect: a console always exits when it is done.
-sSilent: nothing on standard output or standard error, and no question is asked (a question stops the run). The log file still records why.
-l <file>Write the log to the file given next.

-c and -b together are refused with exit code 5.

Sizes accept the units KB, MB and GB (1024-based). Decimals are allowed, for example 1.5MB.

OptionMeaning
-o, --dest <folder>Destination folder, created if needed. Default: the source's folder.
--size <N>Piece size on disk. Default: 1 MB.
--pieces <N>Number of pieces; the size is computed from it.
--first-sizes <list>Progressive split: the first pieces take the listed sizes (--first-sizes 10MB,50MB,250MB), then every piece takes --size. Size mode only: refused (exit 3) with --pieces, --pattern, --lines, --csv or --spanned.
--from-endFill the pieces from the end: the last piece is full and piece 1 takes the remainder. Refused (exit 3) with --first-sizes, --pattern, --lines, --csv and --spanned.
--only <list>Create only these pieces: 1, 3-5, 37- (37- means from 37 to the end). Refused (exit 3) with --gunite and --join-script. Nothing selected inside the set is exit 0 with a warning.
--spannedOne piece per disk. The console asks for the next disk.
--reserve-first <bytes>, --reserve-other <bytes>Space left free in piece 1, and in the other pieces.
OptionMeaning
--pattern <text>Pieces end after the pattern. 0xHH is one byte; 0x0D0x0A is CR LF.
--occurrences <N>Occurrences of the pattern per piece.
--beforeCut before the pattern instead of after it.
--lines <N>Text mode: pieces of N lines. --pieces <N> instead gives N pieces by line count. Text pieces are plain text named {ofw}_{oru}{ore}, without metadata, unless you give --mask or --metadata.
--csvText mode with RFC 4180 records: a quoted field may span lines. Needs --lines or --pieces.
--max-size <N>Text mode only (exit 3 otherwise): a piece also ends at the last line that keeps the file within N bytes, header, footer, byte order mark and metadata included. A single longer line makes a piece of its own, with a warning.
--regex <expr>Text mode: a record ends at each match of the regular expression instead of at a line feed. Needs --lines; refused (exit 3) with --csv. An invalid expression is exit 3.
--regex-group <N>Cut at capture group N. Default 0, the whole match.
--regex-beforeCut before the group instead of after it.
--metadataText mode: keep the GSplit metadata, so the pieces are a set GUnite can join.
--header <text>Repeated at the start of pieces 2 to n. An empty text is the automatic header.
--header-lines <N>Lines taken by the automatic header. Default 1.
--first-lineRepeat the first line of the file at the start of pieces 2 to n.
--header-firstThe typed header also opens piece 1. Refused (exit 3) when the source has a byte order mark.
--footer <text>Written at the end of every piece.
--bomRepeat the source's byte order mark at the start of pieces 2 to n.
OptionMeaning
--mask <mask>Piece names. {num} or {oru} is required; {orf}, {ofw} and {ore} are available as in the window. Default: disk{num}.gsd.
--title <text>, --author <text>, --desc <text>Piece set metadata, cut to 255, 255 and 4096 characters.
--id <text>A UUID becomes the set id. Any other text is kept as the set label (255 characters) next to a new UUID drawn at each run.
--no-headersRaw pieces without metadata. Join them with copy /b, cat or gunitec.
--rawRaw pieces named {orf}.{oru} (report.pdf.001, report.pdf.002), readable by HJSplit, 7-Zip, Total Commander, copy /b and cat. It is --no-headers plus that mask, unless you give --mask.
OptionMeaning
--crc-fileWrite <name>.crc (Total Commander format). Needs --no-headers or --raw (exit 3 otherwise).
--manifestWrite <name>.sha256 with the SHA-256 of every piece and of the original, in sha256sum -c format. Refused (exit 3) with --spanned.
--join-scriptWrite <name>.join.bat and <name>.join.sh. Refused (exit 3) with --spanned.
--guniteCopy the Self-Uniting app (GUnite.exe next to the host, else gunitec.exe; GUnite, else gunitec, on Linux) and its .ini next to the pieces. The Self-Uniting settings come from a project file.
OptionMeaning
-y, --overwriteReplace existing pieces. Same as --overwrite-policy overwrite.
--overwrite-policy <policy>What to do when a piece name already exists: refuse (default, exit 3), overwrite, skip, rename or ask.
--empty-destEmpty the destination folder first. Refused when it contains the source.
--verifyRead each piece back (size and CRC-32).
--checkValidate everything and write no piece. The summary says which metadata the run would write.

The policies:

  • skip leaves an existing piece alone and does not write it again. It finishes an interrupted run made with the same settings. A file is kept only when it has exactly the size the run would write and, with metadata, a GSplit trailer of the right number, data size and set id. Anything else is written again. skip is refused with --spanned.
  • rename writes the set under the mask prefixed with (2) , (3) and so on, the first free one. The console prints the mask it used.
  • ask lists the existing pieces and asks [O]verwrite, [R]ename, [S]kip, [Q]uit. With -n, -s or --check it behaves as refuse.

Every piece is written under the name <name>.gspart and moved onto its final name once it is complete. A run that is killed or fails leaves a .gspart file at most, never a half-written piece under its final name.

OptionMeaning
--throttle <N>Cap the read and write rate at N bytes per second (--throttle 5MB is 5 MB/s). The files are the same; the run takes longer.
--block-pause <ms>Wait that many milliseconds (0 to 60000) after each I/O block. Can be combined with --throttle.
--buffer <KB>I/O buffer, 1 to 65536 KB. Default 64.
-nNon-interactive: never ask, a question stops the run.
-q, --quietNo progress and no log lines on standard output. Errors still go to standard error (-s silences those too).
--log <file>Same as -l.
--project <file>, --batch <file>Same as -c and -b, with the file named directly.
--lang <code>Language of the messages (fr, zh_TW, en). Default: the GSPLIT_LANG environment variable, then the language set in Options, then the display language of the system. The letters of the answers (y, R, S, Q) stay the English ones.
-h, --help, -?Print the banner and the usage.

gsplitc - splits what arrives on standard input.

Terminal window
type big.iso | gsplitc - --raw --size 100MB -o D:\out

GSplit first copies the input to a temporary file in the temporary folder, with a random name, and deletes it at the end, also after an error. The set is named as if the source were called stdin: {orf} and {ofw} give stdin, {ore} is empty, and --raw gives stdin.001, stdin.002. The pieces go to the current folder unless -o names another one.

Standard input holds the data, so a question stops the run as with -n. - cannot be combined with -c or -b (exit 5). A copy that fails is exit 1.

Split into 700 MB pieces in another folder, with a SHA-256 manifest and join scripts:

Terminal window
gsplitc "D:\video\film.mkv" --size 700MB -o "E:\pieces" --manifest --join-script

Split a log file into pieces of 10 000 lines, at most 5 MB each, repeating the first line:

Terminal window
gsplitc "D:\logs\access.log" --lines 10000 --max-size 5MB --first-line -o "D:\logs\parts"

Check a project without writing anything, then run it:

Terminal window
gsplitc -c "D:\projects\backup.gsc" --check
gsplitc -c "D:\projects\backup.gsc" -n -l "D:\projects\backup.log"

Use the exit code in a script:

Terminal window
gsplitc "D:\data\archive.bin" --size 1GB -o "E:\out" -n
if errorlevel 1 echo Split failed with code %errorlevel%

In a console, without -n or -s, the run asks the questions the window would ask.

SituationAnswers
Not enough space on the diskR retries after you free space, Q stops (exit 4).
A piece was not copiedC ignores it and continues, Q stops (exit 4).
Next disk required (spanned), or first pieceEnter continues with the disk now in the drive, a folder name writes there, Q stops (exit 4, the pieces are kept).

When standard input is at its end (CI, < NUL, a closed pipe), it counts as Q: a run that needs an answer stops with exit 4.

CodeMeaning
0Success.
1The source file is not found or not readable.
2The destination is missing or not writable.
3Invalid settings: size, pattern, mask, project file, batch file, or pieces that already exist.
4The split failed or was stopped: a question answered with stop (or -n or -s), pattern not found, a piece not written, verification failed, or the source changed during the run.
5Usage error or nothing to do: no source, unknown option, -c with -b. No log file is written.

A failed fixed-size run deletes the pieces it wrote. A spanned run keeps them, and the log names them.

The command line reads the Options of the window. From lowest to highest priority:

  1. the built-in defaults;
  2. the Options, including the default project;
  3. the project file given with -c, or the ConfigFile of a batch;
  4. the batch file;
  5. the options of the command line.

If the default project is missing or unreadable, gsplitc says so on standard error and goes on with the defaults. The exit code does not change. The Options also hold Move erased files and folders to the Recycle Bin: with --empty-dest, the destination's content goes to the Recycle Bin on Windows. On Linux it is deleted.

The settings file gsplit-pref.json is in %APPDATA%\GDG Software\GSplit\ on Windows and in $XDG_CONFIG_HOME/GDG Software/GSplit/ on Linux. The environment variable GSPLIT_CONFIG_DIR replaces that folder.

-l, --log or the LogFile key of a batch writes every line of the run: a header with the version and the date, the source, the destination, the settings, the start and end of each piece with its size and CRC-32, the engine messages and the result. The log is written whatever the exit code.

Back to top

Screenshot