ftp_list

Lists files and directories at a specified path on the FTP/SFTP server. Must be used inside an ftp_session block.

{% ftp_session host: "ftp.example.com", user: "myuser", password: "mypass" %}
  {% ftp_list path: "/data" as result %}

  {% if result.ok %}
    {% for file in result.files %}
      {% log file.name %}
    {% endfor %}
  {% endif %}
{% endftp_session %}

Syntax

{% ftp_list path: "/directory/path" as result_variable %}

Parameters

Parameter
Required
Description

path

Yes

Directory path to list

pattern

No

Glob pattern to filter files (e.g., "*.csv")

Result Object

Property
Type
Description

ok

boolean

true if listing succeeded

error

string/null

Error message if ok is false, null on success

files

array

Array of file objects

Example result:

File Object Properties

Property
Type
Description

name

string

File or directory name

path

string

Full path to the file

type

string

"file" or "dir"

size

number

File size in bytes

modifiedAt

number

Unix timestamp of last modification

Examples

List all files:

Filter by pattern:

Filter files only (exclude directories):

Sort by modification date:

Notes

  • Must be used inside an ftp_session block

  • Consumes 2 credits per operation

  • Pattern uses glob syntax (e.g., *.csv, report_*.txt, **/*.json)

  • Returns empty files array if directory is empty

Last updated