# Option to exclude in test-filters result string when exclude: "=\> (\*.BAK) || (\*.TMP) || (\*.~\*)"

**URL:** <https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492>\
**Category:** Features\
**Created:** [February 14, 2018, 8:47am UTC](https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492 "2018-02-14T08:47:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![avmaksimov](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/a/f475e1/32.png) [@avmaksimov](https://forum.duplicati.com/u/avmaksimov)\
**Post date:** [February 14, 2018, 8:47am UTC](https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492/1 "2018-02-14T08:47:52Z")

</div>

I think it’s be useful string, because if you have many filters it’s very disturbing.

Or may be should be the reason of exclude (without “or” / “II”).

---

<div class="post-metadata">

**Author:** ![thommyX](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thommyX](https://forum.duplicati.com/u/thommyX)\
**Post date:** [February 15, 2018, 7:11am UTC](https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492/2 "2018-02-15T07:11:24Z")

</div>

You can use a regular expression for things like that.

```
--exclude="[.*\.(bak|tmp)$]"

```

Does the job:

```
"Duplicati.CommandLine.exe" test-filters "c:\temp\test\\" --exclude="[.*\.(bak|tmp)$]"

Including source path: c:\temp\test\
Including folder: c:\temp\test\
Excluding path due to filter: c:\temp\test\hugo.bak => ([.*\.(bak|tmp)$])
Including file: c:\temp\test\hugto.baka (374 Bytes)
Including folder: c:\temp\test\x.bak\
Including file: c:\temp\test\x.bak\test (328 Bytes)
Matched 2 files (702 Bytes)

```

Files with .bak AT THE END are excluded but a directory .bak is included!

---

<div class="post-metadata">

**Author:** ![avmaksimov](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/a/f475e1/32.png) [@avmaksimov](https://forum.duplicati.com/u/avmaksimov)\
**Post date:** [February 15, 2018, 10:09am UTC](https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492/3 "2018-02-15T10:09:09Z")

</div>

Yes, but sometimes I need to exclude empty dirs or dirs without added files. Can I do this?

---

<div class="post-metadata">

**Author:** ![thommyX](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thommyX](https://forum.duplicati.com/u/thommyX)\
**Post date:** [February 15, 2018, 6:01pm UTC](https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492/4 "2018-02-15T18:01:59Z")

</div>

Yes you can. With regex you can rule the world 😄

Exclude a directory with a given name but include a file with the same name:

```
C:\temp>"c:\Program Files\Duplicati 2\Duplicati.CommandLine.exe" test-filters "c:\temp\test\\" --exclude="[.*\\hugo3\.bak\\]"
Including source path: c:\temp\test\
Including folder: c:\temp\test\
Excluding path due to filter: c:\temp\test\hugo3.bak\ => ([.*\\hugo3\.bak\\])
Including file: c:\temp\test\hugo.bak (326 Bytes)
Including file: c:\temp\test\hugo2.bak (374 Bytes)
Including folder: c:\temp\test\test\
Including file: c:\temp\test\test\hugo3.bak (462 Bytes)

```

Or you can exclude directories that end with .bak but include files with .bak

```
C:\temp\test>"c:\Program Files\Duplicati 2\Duplicati.CommandLine.exe" test-filters "c:\temp\test\\" --exclude="[.*\.bak\\]"
Including source path: c:\temp\test\
Including folder: c:\temp\test\
Excluding path due to filter: c:\temp\test\hugo3.bak\ => ([.*\.bak\\])
Including file: c:\temp\test\hugo.bak (326 Bytes)
Including file: c:\temp\test\hugo2.bak (374 Bytes)
Including folder: c:\temp\test\test\
Including file: c:\temp\test\test\hugo3.bak (462 Bytes)

```

Or exclude .bak-Files but include .bak-Directories

```
Including source path: c:\temp\test\
Including folder: c:\temp\test\
Excluding path due to filter: c:\temp\test\hugo.bak => ([.*\.bak$])
Excluding path due to filter: c:\temp\test\hugo2.bak => ([.*\.bak$])
Including folder: c:\temp\test\test\
Excluding path due to filter: c:\temp\test\test\hugo3.bak => ([.*\.bak$])
Including folder: c:\temp\test\hugo3.bak\
Including file: c:\temp\test\hugo3.bak\test (328 Bytes)

```

Or exclude both. Files that end with .bak and Directories that end with .bak but include files with .bakxxx

```
Including source path: c:\temp\test\
Including folder: c:\temp\test\
Excluding path due to filter: c:\temp\test\hugo3.bak\ => ([.*\.bak($|\\)])
Excluding path due to filter: c:\temp\test\hugo.bak => ([.*\.bak($|\\)])
Excluding path due to filter: c:\temp\test\hugo2.bak => ([.*\.bak($|\\)])
Including file: c:\temp\test\test.bakxxx (511 Bytes)
Including folder: c:\temp\test\test\
Excluding path due to filter: c:\temp\test\test\hugo3.bak => ([.*\.bak($|\\)])

```

---

<div class="post-metadata">

**Author:** ![avmaksimov](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/a/f475e1/32.png) [@avmaksimov](https://forum.duplicati.com/u/avmaksimov)\
**Post date:** [February 15, 2018, 7:19pm UTC](https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492/5 "2018-02-15T19:19:33Z")

</div>

> [@thommyX](#):
>
> With regex you can rule the world 😄

Thank you for all.

Uhhh… Regex is too hard for me)) and think most of people.

BTW, about tes-filters: may be exists or may be it will be nice feature to optionally exclude strings begining "Excluding path due to filter: ".

---

<div class="post-metadata">

**Author:** ![thommyX](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/e47774/32.png) [@thommyX](https://forum.duplicati.com/u/thommyX)\
**Post date:** [February 17, 2018, 10:24am UTC](https://forum.duplicati.com/t/option-to-exclude-in-test-filters-result-string-when-exclude-bak-tmp/2492/6 "2018-02-17T10:24:07Z")

</div>

I do not understand what you mean. Can you give an example?

If you want to try regex you can use this to learn: [https://regex101.com/](https://regex101.com/)  
There you have an explanation and a quick reference. You just need to enable multi line if you want to test file paths with line separation:

 ![image](https://forum.duplicati.com/uploads/default/original/2X/c/c78568e3769f11e63afcf3c9d68e718e0562e597.png)
