Back to blog

How to Find and Check if a File Exists on SFTP

Search for files on SFTP/FTP/S3 before downloading or processing them in Zapier.

·5 min read

Check Before You Act

Many Zapier workflows assume a file exists before they download, read, or process it. But files aren't always there — they might arrive late, have a different name, or not be generated at all. PushFTP's Find File search in Zapier lets you check if a file exists on your SFTP, FTP, or S3 server before your workflow depends on it.

All lookups go through PushFTP's fixed IP address — the same one your server already trusts for uploads and downloads.

What You Need

  • A PushFTP account with a connection (sign up free)
  • PushFTP's static IP whitelisted on your server
  • A Zapier account

Step 1: Add Find File as a Search Step

In Zapier, Find File is a search action (not a trigger or regular action). You can use it:

  • In a Zap's action steps, to look up a file before doing something with it
  • As a search step paired with another action

Add it to your Zap:

  1. App: PushFTP
  2. Action type: Search
  3. Event: Find File
  4. Account: Your PushFTP account

Configure:

Connection: My SFTP Server
Path: /exports/
Filename: daily-report.csv

PushFTP searches the specified directory for the filename and returns the file details if found (path, size, modified date) or an empty result if not.

Step 2: Handle the Result

The key is what you do when the file does or doesn't exist.

File exists → process it

Search: PushFTP → Find File (/exports/daily-report.csv)
Filter: Only continue if file found
Action 1: PushFTP → Download File
Action 2: Gmail → Send Email with attachment

File doesn't exist → alert or skip

Search: PushFTP → Find File (/exports/daily-report.csv)
Path A (found): PushFTP → Download File → process
Path B (not found): Gmail → Send alert email

Zapier's Paths feature lets you branch based on whether Find File returned a result. Check the Zapier integration docs for branching examples.

Step 3: Test It

Put a test file on your server, then run Find File targeting it. Verify you get the file details back. Then change the filename to something that doesn't exist and verify you get an empty result.

# Create test file
echo "test" | sftp user@server:/test/ <<< "put /dev/stdin find-test.txt"

Search for find-test.txt in /test/ — should return found. Search for nonexistent.txt — should return not found.

Common Workflows

Wait for a File Before Processing

Some files are generated by scheduled jobs that might run late. Instead of failing:

Trigger: Schedule → Every 15 minutes (starting at expected time)
Search: PushFTP → Find File
  Path: /exports/
  Filename: daily-report-{{date}}.csv
Filter: Only continue if found
Action 1: PushFTP → Download File
Action 2: (process)
Action 3: Zapier → Turn off this Zap (or use a flag to prevent reprocessing)

This polls until the file appears, then processes it.

Avoid Overwriting on Upload

Check if a file already exists before uploading:

Trigger: (produces a file to upload)
Search: PushFTP → Find File
  Path: /uploads/
  Filename: {{filename}}
Filter: Only continue if NOT found
Action: PushFTP → Upload File
  Path: /uploads/{{filename}}

If the file already exists, the Zap stops. No accidental overwrites. See the upload guide for upload configuration.

Validate Before Moving

Confirm a file exists before trying to move it:

Search: PushFTP → Find File
  Path: /incoming/
  Filename: {{expected_file}}
Filter: Only continue if found
Action: PushFTP → Move File
  From: /incoming/{{expected_file}}
  To: /processed/{{expected_file}}

This prevents "file not found" errors in the move step. The move guide covers more patterns.

Check Multiple Locations

If a file could be in one of several directories:

Search 1: PushFTP → Find File in /incoming/
Search 2: PushFTP → Find File in /uploads/
Search 3: PushFTP → Find File in /archive/
Code step: Determine which search found it
Action: PushFTP → Download File from the right path

Existence Check for Monitoring

Monitor that expected files are being generated:

Trigger: Schedule → Every Day at 10am
Search: PushFTP → Find File
  Path: /exports/
  Filename: daily-report-{{yesterday_date}}.csv
Path A (found): ✓ All good, no action needed
Path B (not found): Gmail → Send alert
  Subject: ⚠️ Yesterday's report was not generated

Catch missing files before someone downstream complains.

Find File on S3

Works the same way. Specify the S3 prefix as the path and the object name as the filename:

Connection: My S3 Bucket
Path: exports/2025/01/
Filename: report.csv

PushFTP checks the bucket through its static IP, respecting any bucket policies you have in place.

Partial Filename Matching

Find File searches for an exact filename match. If you need pattern matching (e.g., find any file starting with "report-"), use List Files instead and filter the results in Zapier:

Action 1: PushFTP → List Files (/exports/)
Action 2: Filter → Only continue if filename contains "report-"

Or use Run SSH Command for server-side pattern matching:

Action: PushFTP → Run SSH Command
  Command: ls /exports/report-*.csv 2>/dev/null | head -1

If the command returns output, the file exists. If empty, it doesn't. Check the SSH commands guide for more.

Checking before acting prevents broken workflows and wasted Zapier tasks. One search step, one filter, and your Zap only proceeds when the file is actually there. Simple, reliable, and easy to set up.

FAQ

Does Find File search subdirectories?

No. Find File searches only the specified directory — not recursively. If the file could be in a subdirectory, you'll need to search each one separately or use the SSH command approach with find.

Can I search by file extension instead of exact name?

Not directly. Find File uses exact filename matching. For extension-based searches, use List Files and filter the results by extension in Zapier.

Does a Find File search count as a transfer?

Yes. Each search counts as one transfer on the free plan (50/month). On paid plans, searches are unlimited.

What if the file exists but I don't have read permission?

Find File checks the directory listing. If the file appears in the listing (you have read permission on the directory), it reports the file as found — even if you can't read the file itself. Permission errors would surface when you try to download or read the file.

Look Before You Leap

Find File is the safety net for file workflows. It turns "hope the file is there" into "verify the file is there." A few seconds of checking saves you from failed downloads, missing data, and confused error messages. Add it before any action that depends on a specific file existing.

Ready to automate your file transfers?

Connect to any SFTP, FTP, or S3 server from a fixed IP address. Free plan available — no credit card required.