# Branch task

A Branch is where a job parts into several paths. It is the only task with more than two ways out: between 2 and 20 numbered dots, each leading to a path of its own.

In CrushMFT 27 a dot has one line. Wherever a job shall do several things with the same files, a Branch says so. See [How a job flows](Jobs-Flow.md).

## Fields

| Field | What it does | On a new task |
|---|---|---|
| **Dots** | how many ways out, 2 to 20 | 2 |
| **Run the dots** | **All at once**, or **One after another, in dot order** | All at once |
| per dot: a name | a word for the dot, shown on the canvas and in the log | |
| per dot: a filter | which items this dot gets. A pattern compared with each item's address. | `*` |

> Each dot gets its own copy of the items its filter matches, so what one branch does to its items never reaches another. A Wait / Joiner brings the branches back together.

## What each path gets

A **copy** of the items its dot's filter matches.

- With `*` on every dot, every path gets all items: three Copy tasks behind three dots deliver every file to three places.
- With different filters, the Branch sorts: `*.pdf` on dot 1, `*.csv` on dot 2, `*` on dot 3. An item that matches several filters goes down several paths. An item that matches none goes nowhere.
- A dot **without a line** drops its items, with a line in the log: "Branch dot 2 has no line: its items are dropped." The designer warns of it.

Because each path has its own copy, a path can rename, move or exclude its items without the others noticing. What is shared is everything else: [variables](Jobs-Variables.md) belong to the whole run.

## All at once, or one after another

| | All at once | One after another |
|---|---|---|
| The paths | run at the same time | run in the order of their numbers; dot 2 starts when the path of dot 1 has ended |
| Use it | for independent deliveries, to save time | when the order matters, or the paths set the same variables, or the other side cannot take several connections |
| A failure in one path | does not stop the others | does not stop the following ones either |

## Bringing paths together

A path ends at End, at a task with no line out, or at a [Wait / Joiner](Task-Wait.md). The joiner waits for the paths that lead to it and goes on with one list.

A task that several paths lead to **without** a joiner runs once per path. The designer warns: "… is reached by dots 1, 2 of Branch … with no joiner before it: it runs once per dot."

## In the log

```
Branching 7 item(s) into 3 dots, all at once.
Branch dot 1 (archive): 7 item(s).
Branch dot 2 (partner): 2 item(s) matching *.csv.
```

Under Active Jobs, the Branch's card shows how many items each dot was sent.

## Things to know

- **Variables are shared.** Two paths that run at once and both set `{target}` overwrite each other. Give each path its own names, or run the dots one after another.
- **Lists are copied.** For very long lists that costs room: a Branch into five paths of a million items each is five million. See [Jobs with a million items](Jobs-Large-Lists.md).
- **A Branch has no failure dot.** It cannot fail in any interesting way.
- **Jobs from CrushFTP 11** that had several lines on one dot get a Branch there by **Convert to Branch**: see [How a job flows](Jobs-Flow.md#jobs-from-crushftp-11).
- **To send items one way or the other by a value**, not by their address, use a [Jump](Task-Jump.md).
