Command line: GSplit and gsplitc
For scripts, servers and scheduled jobs.
Two programs split from a command line, and both run the same code as the window:
| Program | What it is |
|---|---|
gsplitc (gsplitc.exe on Windows) | The console. Windows and Linux, no window, no WebView2. Use it in scripts, servers and CI. |
GSplit.exe | The 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 --helpgsplitc --version| Form | What 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, --version | Print 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.
Open the window on files
Section titled “Open the window on files”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.
| Command | Result |
|---|---|
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.
--uniteand--file-listare window switches. They never start a command-line run. Any switch of the sections below does, and then no window is created.
GSplit 3 switches
Section titled “GSplit 3 switches”These switches work as in GSplit 3, written separately or joined (-b-i-t).
| Switch | Meaning |
|---|---|
-go | Split 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. |
-i | Execute the batch. |
-t | Accepted, no effect: a console always exits when it is done. |
-s | Silent: 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.
Options
Section titled “Options”Sizes accept the units KB, MB and GB (1024-based). Decimals are allowed, for example 1.5MB.
Destination and size
Section titled “Destination and size”| Option | Meaning |
|---|---|
-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-end | Fill 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. |
--spanned | One 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. |
Text, lines and patterns
Section titled “Text, lines and patterns”| Option | Meaning |
|---|---|
--pattern <text> | Pieces end after the pattern. 0xHH is one byte; 0x0D0x0A is CR LF. |
--occurrences <N> | Occurrences of the pattern per piece. |
--before | Cut 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. |
--csv | Text 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-before | Cut before the group instead of after it. |
--metadata | Text 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-line | Repeat the first line of the file at the start of pieces 2 to n. |
--header-first | The 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. |
--bom | Repeat the source's byte order mark at the start of pieces 2 to n. |
Piece names and metadata
Section titled “Piece names and metadata”| Option | Meaning |
|---|---|
--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-headers | Raw pieces without metadata. Join them with copy /b, cat or gunitec. |
--raw | Raw 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. |
Files written next to the pieces
Section titled “Files written next to the pieces”| Option | Meaning |
|---|---|
--crc-file | Write <name>.crc (Total Commander format). Needs --no-headers or --raw (exit 3 otherwise). |
--manifest | Write <name>.sha256 with the SHA-256 of every piece and of the original, in sha256sum -c format. Refused (exit 3) with --spanned. |
--join-script | Write <name>.join.bat and <name>.join.sh. Refused (exit 3) with --spanned. |
--gunite | Copy 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. |
Existing pieces and verification
Section titled “Existing pieces and verification”| Option | Meaning |
|---|---|
-y, --overwrite | Replace 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-dest | Empty the destination folder first. Refused when it contains the source. |
--verify | Read each piece back (size and CRC-32). |
--check | Validate everything and write no piece. The summary says which metadata the run would write. |
The policies:
skipleaves 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.skipis refused with--spanned.renamewrites the set under the mask prefixed with(2),(3)and so on, the first free one. The console prints the mask it used.asklists the existing pieces and asks[O]verwrite, [R]ename, [S]kip, [Q]uit. With-n,-sor--checkit behaves asrefuse.
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.
Low impact, buffer and output
Section titled “Low impact, buffer and output”| Option | Meaning |
|---|---|
--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. |
-n | Non-interactive: never ask, a question stops the run. |
-q, --quiet | No 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. |
Read from standard input
Section titled “Read from standard input”gsplitc - splits what arrives on standard input.
type big.iso | gsplitc - --raw --size 100MB -o D:\outcat big.iso | gsplitc - --raw --size 100MB -o outGSplit 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.
Examples
Section titled “Examples”Split into 700 MB pieces in another folder, with a SHA-256 manifest and join scripts:
gsplitc "D:\video\film.mkv" --size 700MB -o "E:\pieces" --manifest --join-scriptgsplitc ~/video/film.mkv --size 700MB -o /mnt/usb/pieces --manifest --join-scriptSplit a log file into pieces of 10 000 lines, at most 5 MB each, repeating the first line:
gsplitc "D:\logs\access.log" --lines 10000 --max-size 5MB --first-line -o "D:\logs\parts"gsplitc /var/log/access.log --lines 10000 --max-size 5MB --first-line -o ~/partsCheck a project without writing anything, then run it:
gsplitc -c "D:\projects\backup.gsc" --checkgsplitc -c "D:\projects\backup.gsc" -n -l "D:\projects\backup.log"gsplitc -c ~/projects/backup.gsc --checkgsplitc -c ~/projects/backup.gsc -n -l ~/projects/backup.logUse the exit code in a script:
gsplitc "D:\data\archive.bin" --size 1GB -o "E:\out" -nif errorlevel 1 echo Split failed with code %errorlevel%gsplitc /data/archive.bin --size 1GB -o /mnt/out -n || echo "Split failed with code $?"Questions
Section titled “Questions”In a console, without -n or -s, the run asks the questions the window would ask.
| Situation | Answers |
|---|---|
| Not enough space on the disk | R retries after you free space, Q stops (exit 4). |
| A piece was not copied | C ignores it and continues, Q stops (exit 4). |
| Next disk required (spanned), or first piece | Enter 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.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 | Success. |
1 | The source file is not found or not readable. |
2 | The destination is missing or not writable. |
3 | Invalid settings: size, pattern, mask, project file, batch file, or pieces that already exist. |
4 | The 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. |
5 | Usage 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.
Settings that apply
Section titled “Settings that apply”The command line reads the Options of the window. From lowest to highest priority:
- the built-in defaults;
- the Options, including the default project;
- the project file given with
-c, or theConfigFileof a batch; - the batch file;
- 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.
Log file
Section titled “Log file”-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.
