Files

Batch Files

Copies files, in folder order, into numbered batch folders (Batch_0001, Batch_0002 …) that each hold at most a set number of files and/or a set size, with every copy verified.

Free Command line: batch-files Version 1.0

Batch Files splits a collection into smaller folders for upload, review assignment or transfer. Files are taken in natural folder order and copied into the current batch until adding the next file would pass the file limit or the size limit; then a new batch starts. The input is read only and never changed.

The batches are counted before anything is copied. If the batch numbers would not fit in the chosen number of digits, the run stops with nothing copied and says how many digits are needed. Each copy is checked by MD5, and the files keep their created, modified and accessed dates. Running again on the same files gives the same batches and names.

Use it when

How to run it

  1. Choose the folder of files as Input and an Output folder outside it.
  2. Set Max files per batch and/or Max batch size (GB); at least one must be more than 0.
  3. Set the Batch name prefix and Digits for the folder names.
  4. Decide whether to tick Keep sub-folders.
  5. Click Run.
  6. Click Open report, and open batches.csv in the run folder for the per-batch totals.

Settings

Every setting has the same help beside it in the app. On the command line, pass each as --name value; ltk help batch-files lists them.

Settings

SettingWhat it doesType and default
Max files per batch
--max-files
Most files in one batch. 0 means no file limit (then a size limit is needed).
0 means no file limit, in which case a size limit is needed. With both limits set, a batch closes at whichever is reached first.
number
1000
Max batch size (GB)
--max-size-gb
Largest total size of one batch in GB (decimals allowed, e.g. 4.5 or 4,5; no thousands separators). 0 means no size limit (then a file limit is needed). A single file larger than this gets a batch of its own.
Decimals may use a point or a comma (4.5 or 4,5). Do not use thousands separators: a value such as 1,000 is refused as ambiguous. A GB here is 1,024 × 1,024 × 1,024 bytes. A file larger than the limit gets a batch of its own, and a note lists such files.
text
5
Batch name prefix
--prefix
Start of each batch folder's name: Batch_ gives Batch_0001, Batch_0002…
Must be usable in a folder name. It may be empty, giving folders named just by number.
text
Batch_
Digits
--digits
Digits in the batch number (4 gives 0001). If more batches are needed than fit, the run stops before copying anything and says how many digits are needed.
Between 1 and 9. 4 allows up to 9,999 batches.
number
4
Keep sub-folders
--keep-folders
Off (default): files sit directly in their batch folder (clashing names are numbered, never overwritten). On: each file keeps its source sub-folder path inside its batch.
Off: every file sits directly in its batch folder; if two files have the same name, the later one is numbered rather than overwriting, and the Note column says what it was saved as. On: each file keeps its source sub-folder path inside its batch, which avoids most clashes.
yes/no
false

Common settings

SettingWhat it doesType and default
Input required
--input
Folder (or single file) to read. It is opened read-only and never modified. folder
empty
Output required
--output
Folder for reports. Must not be inside the input folder. Each run gets its own sub-folder. folder
empty
Recurse
--recurse
Include sub-folders. yes/no
true
Extensions
--extensions
Only process these extensions (e.g. .pdf, .docx). Empty means the tool's default set. list
empty
Parallelism
--parallelism
Files processed at once. Use 1-2 for spinning disks or network shares. number
4

What you get

Each run creates its own folder inside the output folder, with the report batch-files.csv, errors.csv and manifest.json (see Run folders and manifests).

Report columns

Check the result

Tips
  • Names ending in a dot or space, which Windows cannot create, are saved ending in _ instead; the row says so.
  • Sort or rename folders before running if the batch order matters, because files are batched in natural folder order.
Watch out for
  • Batching is by count and size only. The tool does not know about document families, so an email and its attachments can end up in different batches if a batch boundary falls between them.
  • The output needs as much free space as the files being batched, because everything is copied.

From the command line

The command line is part of LitTechKit Pro. See Command line.

ltk run batch-files --input "D:\Matter\ForUpload" --output "D:\Matter\Batches" --max-files 1000 --max-size-gb 4.5 --prefix Batch_ --digits 4

Related tools