dirsplit
Split directory hierarchy into individual paths
SYNOPSIS
dirsplit [OPTION]... DIRECTORY [TARGET]
PARAMETERS
-h, --help
display this help and exit
-V, --version
output version information and exit
-s, --size=SIZE
maximum size per subdirectory (default: 650m, suffixes: k,m,g)
-n, --number=NUM
maximum number of files per subdirectory (default: 0, unlimited)
-p, --prefix=PREFIX
prefix for created subdirectories (default: cdimage)
-v, --verbose
increase verbosity
-q, --quiet
suppress non-error messages
DESCRIPTION
dirsplit is a utility designed to divide a large directory structure into multiple smaller subdirectories, primarily for tasks like preparing data for CD/DVD burning or managing file archives.
It employs a bin-packing algorithm, sorting files by size in descending order and distributing them into "bins" (subdirectories) that respect user-defined size or file count limits.
This prevents any single subdirectory from exceeding specified capacities, making it ideal for optical media where discs have fixed sizes (e.g., 650MB for CDs).
The tool creates numbered subdirectories with a customizable prefix (default: cdimage) under an optional target directory. It supports verbose output and handles recursion implicitly by processing the entire directory tree.
Usage is straightforward for archiving large datasets, backups, or distribution packages.
CAVEATS
Does not preserve original directory structure; files are flattened and repacked. No hard links or symlinks handling. Target directory must not exist or be empty.
ALGORITHM
Uses first-fit decreasing bin packing: sorts files largest-first, places into first fitting bin.
EXAMPLES
dirsplit /path/to/large/dir (splits into cdimage00, cdimage01...)
dirsplit -s 4.7g -p dvd /data /mnt/backup (DVD-sized splits)
HISTORY
Originally developed around 2000 by Joey Hess for Debian tools, aimed at CD image creation. Maintained in util-linux-ng and Debian repos; stable with minor updates for modern filesystems.


