Docs

RunMacro Documentation

Learn RunMacro from basics to advanced.

Everything you need to start and master RunMacro — from basic commands to advanced automation workflows.

RunMacro robot
Docs File List Files and Folders
📋 File

List files and folders in RunMacro

List Files and Folders scans a folder by pattern, filters by kind, optionally recurses, then saves the list and count to variables.

Prerequisites

  • The folder exists and is readable.

Supported modes

  • Desktop ModeOperates on the local file system.
  • Browser Mode

What it does

The List Files and Folders command scans a folder and returns items matching a pattern (e.g. *.png). You can filter by kind (file/folder), recurse into subfolders, and choose the result format and how paths are shown. The list and its count are saved to variables.

When to use it

  • Get a file list to loop over and process each one.
  • Count files matching a pattern.
  • Walk a folder tree to collect data.

When not to use it

  • You only need to check if one file exists — use IF File Exists.

Configuration steps

  1. Add a File › List Files and Folders command.
  2. Enter the folder and a pattern (default * = everything).
  3. Choose the kind (file/folder/any) and whether to recurse.
  4. Choose the result format (one per line or JSON) and return mode (full path / name only / relative path).
  5. (Optional) Rename the list and count variables. Save.

Every option explained

Folder path

The folder to scan.

Pattern

A glob pattern like *, *.txt. Default matches everything.

Entry kind

file, folder, or any.

Recursive

If on, scans subfolders too.

Result format

newline (one item per line) or json (a JSON array).

Return mode

full_path, name (name only), or relative_path (relative to the scanned folder).

List variable / Count variable

Variable for the list (default directory_entries) and for the count (default directory_entry_count).

Expected result

The list variable holds the matching items (sorted); the count variable holds the total.

Real example

Example: loop over every PNG

  1. List: images folder, pattern *.png, kind = file, return = full path.
  2. Feed {directory_entries} into a Loop to process each image.

Limitations and failure cases

  • Very large listings can use memory when stored in a single variable.

Tips & common mistakes

Use the one-per-line format for easy looping; use JSON when another step needs to read an array.

Verification details

  • commands/filesystem.py
RunMacro robot

Ready to automate smarter?

Download RunMacro and start automating your desktop, browser, and business workflows today.