# Glob Filter

Filter a pasted path list with glob or gitignore-style include and exclude patterns, then preview matched, unmatched, or annotated results.

## Run it

- **CLI:** `gizza tool glob-filter "src/main.rs
src/lib.rs
tests/app.test.ts
target/debug/app
README.md"`
- **Web:** https://gizza.ai/tools/glob-filter/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/glob-filter/tool.json

## Inputs

- `paths` — Paths (one per line) _(field)_
- `include` — Include patterns _(field)_
- `exclude` — Exclude patterns _(field)_
- `syntax` — Pattern syntax _(field)_
- `case_sensitive` — Case-sensitive matching _(field)_
- `output` — Output _(field)_

## Output

- Filtered paths (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `paths` — Paths (one per line)
- `include` — Include patterns
- `exclude` — Exclude patterns
- `syntax` — Pattern syntax
- `case_sensitive` — Case-sensitive matching
- `output` — Output

Example: `https://gizza.ai/tools/glob-filter/?paths=src%2Fmain.rs%0Asrc%2Flib.rs%0Atests%2Fapp.test.ts%0Atarget%2Fdebug%2Fapp%0AREADME.md&include=%2A.rs%0A%2A.md&exclude=target%2F%0A%21target%2Fkeep.txt&syntax=gitignore&case_sensitive=true&output=matched`

---

## About this tool

Glob Filter lets you paste a list of paths and preview which ones match include and exclude patterns. It is useful for designing `.gitignore`, Docker ignore, CI include/exclude, packaging, and code-search file filters before applying them to a real repository.

Use **gitignore-style** syntax when you want familiar `.gitignore` behavior: patterns without `/` match at any depth, `/` anchors to the root, directory patterns cover everything below them, blank lines and `#` comments are ignored, and `!` can re-include a later exception. Use **whole-path glob** syntax when each pattern should match the entire path and `**/` is required for any-depth matches.

## Worked example

Paths:

```text
src/main.rs
src/lib.rs
tests/app.test.ts
target/debug/app
README.md
```

Include patterns:

```text
*.rs
```

Exclude patterns:

```text
target/
```

With **Pattern syntax = gitignore-style** and **Output = Matched**, the result is:

```text
src/main.rs
src/lib.rs
```

## Syntax notes

- `*` matches characters within one path segment.
- `**` spans directories; in whole-path glob mode, use `**/*.rs` for Rust files at any depth.
- `?` matches one non-slash character.
- `[abc]`, `[a-z]`, and `[!0-9]` character classes are supported.
- `{png,jpg,gif}` brace alternatives are supported.
- `!pattern` negates a later pattern line in the same include or exclude list; the last matching line wins.

## Limits & edge cases

- This tool filters a pasted path list; it does not walk your filesystem or upload folders.
- Matching uses `/` as the path separator. Convert Windows backslashes first if needed.
- In gitignore-style mode, a pattern like `*.rs` matches at any depth. In whole-path glob mode, `*.rs` only matches top-level paths.
- Exclude patterns run after include patterns; a path is kept when it is included and not excluded.
- Case-sensitive matching is on by default. Turn it off for case-insensitive filesystems or mixed-case path lists.

## FAQ

<details>
<summary>What is the difference between glob and gitignore-style syntax?</summary>

Whole-path glob treats every pattern as matching the complete path, so `*.rs` matches `main.rs` but not `src/main.rs`; use `**/*.rs` for any depth. Gitignore-style syntax follows `.gitignore` conventions, so `*.rs` matches Rust files anywhere in the path list.

</details>

<details>
<summary>How do include and exclude patterns combine?</summary>

A path is kept if it matches the include list (or the include list is empty) and it does not match the exclude list. Exclude patterns therefore remove paths after the include step. Within each pattern list, later lines override earlier ones when you use `!` negation.

</details>

<details>
<summary>Can I test a real folder directly?</summary>

No. The tool is text-in/text-out and browser-local: paste paths from commands such as `git ls-files`, `find`, or a build log. That keeps the page portable and avoids filesystem permissions or uploads.

</details>

<details>
<summary>Does it support comments and negation like .gitignore?</summary>

Yes in gitignore-style mode. Blank lines and `#` comments are ignored, and a leading `!` re-includes paths in the same include or exclude list. Escape a literal leading `#` or `!` with a backslash.

</details>

## Related tools

- [Base Decoder](https://gizza.ai/tools/base-decoder/): Auto-detect and decode Base16, Base32, Base45, Base58, Base64, and Base85 text, including nested layers, locally in your browser.
- [Before / after image slider generator](https://gizza.ai/tools/before-after-slider/): Turn two images into an interactive before/after comparison slider: one self-contained HTML file with inline CSS + JS, no libraries.
- [BSON Inspector](https://gizza.ai/tools/bson-inspector/): Paste BSON bytes as base64 or hex and inspect a typed tree or canonical MongoDB Extended JSON v2 with ObjectId, dates, binary, and int64 preserved.
- [Preview a Bulk File Rename](https://gizza.ai/tools/bulk-file-renamer/): Preview old-to-new filename mappings with find/replace, regex, numbering, case conversion, prefix/suffix, and collision warnings.
- [Decode/Transform Recipe Pipeline](https://gizza.ai/tools/cyberchef-pipeline/): Chain byte-level decode/transform steps — Base64, hex, URL, gzip/zlib, XOR, ROT13 — into one recipe, applied top to bottom. Free, private, runs entirely in your browser.
