When You Need a Directory Listing
Before you can download, process, or delete files, you often need to know what's there. PushFTP's List Files action in Zapier returns the contents of a directory on your SFTP, FTP, or S3 server — filenames, sizes, timestamps — so you can make decisions in your workflow.
All connections go through PushFTP's single fixed IP address. One firewall rule covers listing, uploading, downloading, and every other operation.
What You Need
- A PushFTP account with a connection (get started here)
- PushFTP's static IP whitelisted on your server
- A Zapier account
- Read permissions on the remote directory
Step 1: Choose Your Trigger
List Files is usually triggered on a schedule or as part of a larger workflow:
Scheduled inventory:
Trigger: Schedule → Every Day at 9am
Before processing:
Trigger: Webhooks → POST from your backend
After an event:
Trigger: Google Sheets → New Row (containing a folder path)
Step 2: Add the List Files Action
In your Zap:
- App: PushFTP
- Event: List Files
- Account: Your PushFTP account
Configure:
Connection: My SFTP Server
Remote Path: /incoming/
The action returns a list of files with details:
[
{
"filename": "invoice-001.pdf",
"path": "/incoming/invoice-001.pdf",
"size": 245760,
"modified": "2025-01-15T10:30:00Z",
"type": "file"
},
{
"filename": "invoice-002.pdf",
"path": "/incoming/invoice-002.pdf",
"size": 189440,
"modified": "2025-01-15T11:00:00Z",
"type": "file"
}
]
You get the filename, full path, size in bytes, modification timestamp, and whether it's a file or directory.
Step 3: Work With the Results
Count Files in a Folder
Action 1: PushFTP → List Files (/incoming/)
Action 2: Code by Zapier
Input: {{file_list from step 1}}
Code: return { count: inputData.file_list.length }
Action 3: Filter → Only continue if count > 0
Action 4: Gmail → Send Email
Subject: {{count}} files waiting in /incoming/
Loop Through and Process Each File
Action 1: PushFTP → List Files (/exports/)
Action 2: Loop → For each file
Action 2a: PushFTP → Download File ({{path}})
Action 2b: Gmail → Send Email with attachment
Action 2c: PushFTP → Move File to /archive/
Check the Zapier integration docs for details on looping through results.
Find Files Matching a Pattern
Action 1: PushFTP → List Files (/reports/)
Action 2: Filter → Only continue if filename contains "monthly"
Action 3: PushFTP → Download File
Monitor Directory Size
Trigger: Schedule → Every Day at midnight
Action 1: PushFTP → List Files (/uploads/)
Action 2: Code by Zapier
const files = JSON.parse(inputData.file_list);
const totalMB = files.reduce((sum, f) => sum + f.size, 0) / 1024 / 1024;
return { totalMB: totalMB.toFixed(2), fileCount: files.length };
Action 3: Google Sheets → Create Row
Date: {{zap_meta_human_now}}
Files: {{fileCount}}
Size (MB): {{totalMB}}
Track storage usage over time without SSH access.
Listing S3 Buckets
For S3 connections, the path is a prefix:
Connection: My S3 Bucket
Remote Path: uploads/2025/01/
This lists all objects with that prefix. S3 doesn't have real directories, but PushFTP normalizes the response so it looks the same as SFTP/FTP listings.
Handling Empty Directories
If the directory is empty, List Files returns an empty array. Your Zap won't error — but subsequent steps that expect files will have nothing to work with.
Add a filter after List Files:
Filter: Only continue if file count > 0
Or use a Code step to check the length and branch accordingly.
Combining List With Other Actions
List Files is often the first step in batch operations:
Batch download:
List Files → Loop → Download File for each
Batch delete (cleanup):
List Files → Filter by age → Loop → Delete File for each
Batch move (organize):
List Files → Loop → Move File to /archive/{date}/{{filename}}
File count alerting:
List Files → Code (count) → Filter (>100) → Email alert
The List action gives you the inventory. Everything else flows from there.
Performance Considerations
- Large directories — if a folder has thousands of files, the listing can be large. Zapier has payload limits, so extremely large directories might need pagination or filtering on the server side
- Nested directories — List Files returns the immediate contents, not recursive subdirectories. To list nested folders, call List Files for each subdirectory
- Polling vs. listing — if you just need to detect new files, use the New File Detected trigger instead of scheduled List Files. It's more efficient and purpose-built for that use case
Directory listings give your workflows eyes on the server. Know what's there before you act on it — filter, loop, decide — all from a simple Zapier action through PushFTP's fixed IP.
FAQ
Does List Files show hidden files?
On SFTP/FTP, hidden files (starting with .) are typically included in the listing. On S3, all objects matching the prefix are listed. Behavior may vary depending on your server configuration.
Can I list files recursively?
No. List Files returns the immediate contents of the specified directory. For recursive listings, you'd need to list each subdirectory separately. On servers that support it, PushFTP's Run SSH Command action can execute find or ls -R for recursive output.
How often should I run a List Files Zap?
Depends on your use case. For monitoring, once a day or every few hours is typical. For processing queues, every 5-15 minutes. Each List operation counts as one transfer on the free plan.
Can I sort or filter the results server-side?
The List Files action returns all files in the directory. Sorting and filtering happens in Zapier using Filter and Formatter steps. If you need server-side filtering, use the Run SSH Command action to run ls with flags or find with conditions.
Build From the Listing
Directory listings are the foundation for batch file operations. Whether you're processing queues, monitoring storage, or cleaning up old files, it starts with knowing what's in the folder. PushFTP makes that one API call away — through a static IP your server already trusts.