# File System

File System plugin.

Available actions:

* [->](/plugins/fs.md#action-handler-write-to-file) - write to file.
* [mkdir](/plugins/fs.md#action-handler-create-directories) - create directory
* [rm](/plugins/fs.md#action-handler-remove-file-or-directory) - remove file or directory
* [mv](/plugins/fs.md#action-handler-move-file-or-directory) - move file or directory
* [cp](/plugins/fs.md#action-handler-copy-file-or-directory) - copy file or directory
* [find](/plugins/fs.md#action-handler-find-files) - find files

## Action Handler: Write to file

**ID:** `com.fireblink.fbl.fs.file.write`

**Aliases:**

* `fbl.fs.file.write`
* `fs.file.write`
* `file.write`
* `->`

**Example 1: Define File Content Inline**

```yaml
->:
  # [optional] file path, if not provided content will be written to temporary location directory.
  # Note: all missing parent directories will be automatically created
  path: /tmp/test.txt

  # [optional]
  # Note: required if "path" (above) and "assignPathTo" (below) is not provided.
  assignPathTo: # follows common assign logic practicies https://fbl.fireblink.com/plugins/common#assign-to

  # [optional]
  # Note: required if "path" and "assignPathTo" (above) is not provided
  pushPathTo: # follows common push logic practicies https://fbl.fireblink.com/plugins/common#push-to

  # [required] content of the file
  content: |-
    test content
```

**Example 2: Define File Content From Other File**

```yaml
->:
  # [optional] file path, if not provided content will be written to temporary location directory.
  # Note: all missing parent directories will be automatically created
  path: /tmp/test.txt

  # [optional]
  # Note: required if "path" (above) and "assignPathTo" (below) is not provided.
  assignPathTo: # follows common assign logic practicies https://fbl.fireblink.com/plugins/common#push-to

  # [optional]
  # Note: required if "path" and "assignPathTo" (above) is not provided
  pushPathTo: # follows common push logic practicies https://fbl.fireblink.com/plugins/common#push-to

  # [required] template file
  # Note: global and then local EJS template processing will be applied to the template before writing
  contentFromFile: /tmp/template.ejs
```

## Action Handler: Create Directories

Create directory (and all parent ones if missing).

**ID:** `com.fireblink.fbl.fs.dir.create`

**Aliases:**

* `fbl.fs.dir.create`
* `fs.dir.create`
* `dir.create`
* `mkdir -p`
* `mkdir`

**Example:**

```yaml
# create "child" directory
# if "parent" is missing it will be also created
mkdir: /tmp/parent/child
```

## Action Handler: Remove File or Directory

Removes file or directory for given path.

**ID:** `com.fireblink.fbl.fs.remove`

**Aliases:**

* `fbl.fs.remove`
* `fbl.fs.rm`
* `fs.remove`
* `fs.rm`
* `rm -rf`
* `remove`
* `rm`

```yaml
# remove "child"
rm: /tmp/parent/child
```

## Action Handler: Move File or Directory

Allows to move/rename file or entire directory.

**ID:** `com.fireblink.fbl.fs.move`

**Aliases:**

* `fbl.fs.move`
* `fbl.fs.mv`
* `fs.move`
* `fs.mv`
* `move`
* `mv`

**Example 1: Move file to other folder**

```yaml
mv:
  # move file.txt
  from: /tmp/source/file.txt

  # to "target" folder
  # note: slash in the end is required if you want to specify a target folder
  to: /tmp/target/
```

**Example 2: Move file to other folder and rename it**

```yaml
mv:
  # move file.txt
  from: /tmp/source/file.txt

  # to "target" folder and rename it to "renamed.txt"
  to: /tmp/target/renamed.txt
```

**Example 3: Move folder contents to other folder**

```yaml
mv:
  # move everything from "source" folder
  # note: slash in the end is required if you want to move folder contents rather then the folder itself
  from: /tmp/source/

  # to "target"
  to: /tmp/target
```

## Action Handler: Copy File or Directory

Allows to copy file or entire directory.

**ID:** `com.fireblink.fbl.fs.copy`

**Aliases:**

* `fbl.fs.copy`
* `fbl.fs.cp`
* `fs.copy`
* `fs.cp`
* `copy`
* `cp`

**Example 1: Copy file to other folder**

```yaml
cp:
  # copy file.txt
  from: /tmp/source/file.txt

  # to "target" folder
  # note: slash in the end is required if you want to specify a target folder
  to: /tmp/target/
```

**Example 2: Copy file to other folder with different name**

```yaml
cp:
  # copy file.txt
  from: /tmp/source/file.txt

  # to "target" folder and name it "renamed.txt"
  to: /tmp/target/renamed.txt
```

**Example 3: Copy folder contents to other folder**

```yaml
cp:
  # copy everything from "source" folder
  # note: slash in the end is required if you want to copy folder contents rather then the folder itself
  from: /tmp/source/

  # to "target"
  to: /tmp/target
```

## Action Handler: Find Files

Find files by mask.

**ID:** `com.fireblink.fbl.fs.find`

**Aliases:**

* `fbl.fs.find`
* `fs.find`
* `find`

**Example:**

```yaml
find:
  # [required] list of masks to find files
  include:
    - /tmp/**/*.txt

  # [optional] list of masks to exclude
  exclude:
    - /tmp/**/*.tmp.txt

  # [required] result storage configuration
  result:
    # [optional] if provided all paths will be relative to give base directory
    baseDir: /tmp

    # [optional]
    # Note: either `assignTo` or `pushTo` is requred
    assignTo: # follows common assign logic practicies https://fbl.fireblink.com/plugins/common#push-to

    # [optional]
    # Note: either `assignTo` or `pushTo` is requred
    pushTo: # follows common push logic practicies https://fbl.fireblink.com/plugins/common#push-to
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fbl.fireblink.com/plugins/fs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
