# File/Folder Operations

This function block provides a single place to perform many common file and folder tasks (list, read, write, move, delete, join paths, etc.). Select the desired operation from the dropdown and the block will present the appropriate inputs and outputs for that operation.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

This block provides dynamic inputs that change depending on the selected operation. Common input names you may see:

`Folder Path` Path to a folder when listing or creating directories\
`Path` Full path to a file when reading, deleting or checking existence\
`File Name` or `Names` Components used for joining paths or building filenames\
`Content` Text content to save or append to a file\
`Source Path` and `Destination Path` Paths used for copy / move operations\
`(Generic)` Other operation-specific inputs may appear depending on the chosen operation

Note: inputs appear and disappear to match the selected operation. Connect only the sockets shown after you pick the operation.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

Outputs also change with the chosen operation. Common output names:

`Files` List of files found in a directory\
`Folders` List of subfolders found in a directory\
`Image Files` / `Video Files` Lists of media files in a folder\
`Name` / `Extension` Parts of a file path returned when splitting\
`Content` File text returned when reading a file\
`Exists` Boolean indicating whether a path exists\
`Lines` File content returned as a list of lines\
`(Generic)` Other operation-specific results may appear

When an operation returns multiple outputs, separate sockets will be added so you can use each result independently.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Choose Operation` A dropdown that lists available file and folder operations. Selecting an operation updates the available input and output sockets.

`Run` (implicit) The block executes the chosen operation when the scenario runs and provides outputs on the matching sockets.

Note: Changing the `Choose Operation` value updates sockets. If you change the operation, re-check any connections to the updated sockets.

## 🎯 Key Features <a href="#features" id="features"></a>

* Dynamic sockets: Inputs and outputs change to match the selected file/folder operation so you only see relevant sockets.
* Wide set of operations: Listing folders, listing images/videos, reading and writing files, appending, creating/deleting directories, copying/moving files, splitting paths, joining path components and more.
* Fine-grained outputs: Many operations provide multiple outputs (for example, listing returns separate files and folders lists).
* Designed for visual workflows: Intended to be connected to other blocks to build file handling flows without scripting.

## 📝 How to use <a href="#usage" id="usage"></a>

1. Select the desired operation from the `Choose Operation` dropdown.
2. The block will update its input and output sockets to match the operation.
3. Connect the required inputs (for example, `Folder Path` or `Path`) from other blocks such as `Choose Folder` or `String Input`.
4. Run the scenario. The results will appear on the output sockets (for example, `Files`, `Content` or `Exists`).
5. If you change the operation, review and reconnect any sockets that moved or changed.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* To pick a folder visually before using file operations, pair this block with `Choose Folder`.
* To process images found in a folder, use the `List Images` operation here and feed the results into `Load Image From Path` or `Load Image`.
* Use `Join Path` (operation) together with the `Mux` block to build full file paths from parts.
* When saving or logging many images, combine with `Image Logger`, `Image Write` or `Multi Image Write` to persist results.
* For structured export of data, send outputs into `CSV Export` or `Data Write Local`/`Data Write Global` blocks.
* Use `String Input` or `String Merge` to prepare text content before saving with a save/append operation.
* When you need to preview files or images returned by list operations, connect to `Show Image` or `Load Image From Path` then `Show Image`.
* If you need to resize images before saving, combine with `Image Resizer`.
* For conditional flows (for example only save when a file does not exist), combine the `Check Existence` operation with logic blocks such as `Logic Input` and `And`/`Or`.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* If no outputs appear after running, verify you selected the correct operation and connected the required inputs visible on the block.
* For permission errors or failures writing files, make sure the target folder path is valid and the application has write permission to that location.
* When paths contain unexpected separators, use the block's join path operation (or provide normalized paths from upstream blocks) to avoid malformed paths.
* If a list operation returns empty results, confirm the folder actually contains matching files (try `List Folder Contents` first).
* After switching the `Choose Operation` selection, re-check connections: socket positions and quantities may have changed.
