# How to Transfer Multiple Files with croc: A Complete Guide

> Learn how to transfer multiple files with croc using simple commands and wildcards. Securely send several files in one session and understand its multiplexing features.

- Repository: [Zack/croc](https://github.com/schollz/croc)
- Tags: how-to-guide
- Published: 2026-07-27

---

**Use `croc send` followed by multiple file paths or a wildcard pattern to transfer several files in a single secure session; croc automatically multiplexes the transfer across parallel TCP ports unless you disable it with `--no-multi`.**

croc is a command-line file transfer tool that moves data securely between computers without prior setup or server configuration. Transferring multiple files with croc requires only listing the files after the `send` command, as the tool automatically manages parallel streams for optimal throughput. This guide explains the exact command syntax and internal mechanics according to the `schollz/croc` source code, including how multiplexing works and when to disable it.

## Basic Syntax for Sending Multiple Files

When you invoke the `send` command, croc treats every argument after it as a file or folder to be transferred. You can specify individual files, use shell wildcards, or pass entire directories.

### Sending Specific Files

List each filename separated by a space. croc will package them into a single transmission session sharing one security code:

```bash
croc send file1.txt file2.txt file3.txt

```

### Using Wildcards

Your shell expands glob patterns before croc processes them, allowing batch selections:

```bash
croc send *.jpg

```

### Sending Folders

When you pass a directory, croc recursively collects its contents. The folder structure is preserved on the receiving end:

```bash
croc send my_picture_folder

```

## How croc Handles Multiple Files Internally

The multi-file capability relies on **multiplexing**—opening several parallel data streams across different TCP ports. This architecture is implemented across three core files in the repository.

### Argument Parsing in src/cli/cli.go

The `send` command is registered in [`src/cli/cli.go`](https://github.com/schollz/croc/blob/main/src/cli/cli.go), which parses the argument list containing your filenames. Whether you provide explicit paths or wildcards, the CLI collects them into a slice that is passed to the core client. This file also registers the `--transfers` and `--no-multi` flags that control downstream behavior.

### Multiplexing Logic in src/croc/croc.go

The core client implementation in [`src/croc/croc.go`](https://github.com/schollz/croc/blob/main/src/croc/croc.go) governs whether to use multiple ports. The `NoMultiplexing` boolean option determines the flow:

- When `false` (the default), croc retains the full list of relay ports returned by the control connection
- When `true` (triggered by `--no-multi`), only the first port is used for all data

The file transfer loop `c.transferWithReconnect` iterates over the supplied paths, encrypts each chunk with the shared session key, and distributes chunks across the available ports. Because all files share the same **session key** and code phrase, the receiver only needs a single command to reconstruct the entire batch.

### TCP Connection Setup in src/tcp/tcp.go

The low-level networking in [`src/tcp/tcp.go`](https://github.com/schollz/croc/blob/main/src/tcp/tcp.go) opens a TCP connection for each port listed in `c.Options.RelayPorts`. The `Options` struct (defined in [`src/tcp/options.go`](https://github.com/schollz/croc/blob/main/src/tcp/options.go)) stores the `Transfers` and `NoMultiplexing` values that drive this logic. By default, croc opens four parallel connections, though this is configurable.

## Optimizing Transfer Performance

You can tune how croc handles multiple files by adjusting the parallelism or disabling it entirely.

### Adjusting Parallel Transfers (--transfers)

The `--transfers` flag controls how many TCP ports croc uses simultaneously. The default is **4**, but you can increase this for high-bandwidth networks:

```bash
croc send --transfers 8 bigvideo.mkv otherfile.pdf

```

Increasing the transfer count allows more files to move concurrently, though it consumes more system resources and requires more open ports on both sender and receiver.

### Disabling Multiplexing (--no-multi)

If you operate behind a strict firewall that blocks additional ports, force single-port mode:

```bash
croc send --no-multi fileA.bin fileB.bin

```

Setting `--no-multi` sets `c.Options.NoMultiplexing` to `true` in [`src/croc/croc.go`](https://github.com/schollz/croc/blob/main/src/croc/croc.go), restricting the entire batch to one TCP connection. This trades speed for firewall compatibility.

## Receiving Multiple Files

The receiver does not need to know how many files are coming. A single command downloads the entire batch:

```bash
croc <code>

```

croc displays progress for each file individually and writes them to the current directory. If you specify `--out <dir>` when receiving, all files are placed in that target folder while maintaining their relative directory structure.

## Summary

- **Multiple files** are sent by listing them after `croc send`, or using wildcards like `*.jpg`
- **Multiplexing** automatically splits transfers across parallel ports (default 4) for faster throughput, controlled by the `NoMultiplexing` option in [`src/croc/croc.go`](https://github.com/schollz/croc/blob/main/src/croc/croc.go)
- **Optimization** is available via `--transfers` (increase parallelism) or `--no-multi` (disable parallelism for firewalls)
- **Single session** encryption means all files share one code phrase and session key, requiring only one command on the receiving side
- **Key files** implementing this behavior include [`src/cli/cli.go`](https://github.com/schollz/croc/blob/main/src/cli/cli.go) (parsing), [`src/croc/croc.go`](https://github.com/schollz/croc/blob/main/src/croc/croc.go) (orchestration), and [`src/tcp/tcp.go`](https://github.com/schollz/croc/blob/main/src/tcp/tcp.go) (connections)

## Frequently Asked Questions

### Can I transfer multiple files with a single croc command?

Yes. Simply list all files after `croc send`, separated by spaces, or use shell wildcards. The receiver only needs to run `croc <code>` once to download all files in the batch, as they share the same encryption key and session.

### How many files can I send at once with croc?

There is no hardcoded limit in the source code. You can send hundreds of files via wildcard patterns or explicit arguments. However, extremely large batches may approach operating system limits on open file descriptors or command-line argument length.

### Why is croc opening multiple ports when I send files?

This is **multiplexing**, a feature enabled by default in [`src/croc/croc.go`](https://github.com/schollz/croc/blob/main/src/croc/croc.go). By opening several parallel TCP connections (controlled by the `--transfers` flag), croc increases total throughput by sending different file chunks simultaneously over separate ports. All connections use the same session key for end-to-end encryption.

### What if my firewall blocks the extra ports?

Use the `--no-multi` flag to force single-port mode. This sets `c.Options.NoMultiplexing` to `true`, causing croc to use only the first relay port for the entire transfer. While this bypasses restrictive firewalls, it reduces transfer speed because files must stream sequentially rather than in parallel.