- Docs
- Automations
- Automation Types
- Delete Files
Delete Files
The Delete Files automation permanently removes files from a selected folder path. It can run on a schedule and supports advanced file matching, making it useful for regular cleanup workflows such as removing temporary files, outdated reports, expired data, or logs no longer needed.
When to Use Delete Files Automation
Use the Delete Files automation when you need to regularly remove files that are no longer needed, especially when those files follow naming patterns or reside in structured folders. This is useful for workflows that generate time-sensitive data such as daily exports, processed reports, or system logs.
This automation is helpful when cleanup actions need to respond to specific events, target certain files while excluding others, or operate across multiple folders with logic tied to folder structure or timestamps.
If your use case only requires removing files based on age and does not need pattern matching or trigger-based execution, consider using the File Expiration feature instead. File Expiration allows Site Administrators to set rules on a per-folder basis that automatically remove unmodified files after a specified number of days, while preserving the folder structure. Use Delete Files automation when you need more selective or event-driven control over file removal.
Source Path and Folder Selection
The source path can be a folder on the main site, a remote server, or a connected child site. You can use wildcards like /*
to target top-level subfolders or /**
to target all subfolders. For example, invoices/*
selects only folders directly beneath invoices
, while invoices/**
targets all folders under that path, at any depth.
When the source is a Mounted Folder or Remote Server, Automations that include glob patterns (like *
or **
) in the source path are supported only when triggered by file actions.
File Matching Rules
You can apply a file name pattern to include only certain files for deletion. Use wildcard expressions such as *.pdf
or **/*.log
to match specific formats or patterns. If no pattern is specified, all files in the selected folder path are eligible for deletion. This makes it easy to remove files such as daily logs, reports, or processed exports that are no longer needed.
You can also define an exclude pattern to skip files you do not want deleted. For example, **/*draft*
skips any file containing the word "draft" in its name. Wildcards support flexible inclusion and exclusion logic to refine your deletion scope.
Pattern Tokens and Dynamic Matching
File name patterns can include dynamic time-related tokens such as %Y
, %m
, or %d
to match files based on when the automation runs. These tokens can reflect date, time, or folder structure, such as the day of the year or the hour of execution. For example, a pattern like %Y-%m-%d-report.csv
matches a file named with that day’s date.
Source path related tokens can also be used to reflect folder hierarchy, such as %p1
or %p2
, representing parent folders. These tokens allow you to build intelligent cleanup rules that adjust automatically based on timing or structure. This helps support workflows like removing monthly exports, deleting shift-based logs, or cleaning up stale files under structured directories.
Files deleted by this automation are permanently removed.
Controlling How Delete Files Automations Are Executed
When triggered by file actions or webhooks, Delete Files automations may run in parallel if multiple events occur close together. This improves performance but can cause issues when working with remote mounts. Enable the Always Serialize Jobs setting to run each automation one at a time. This helps prevent file conflicts or race conditions on remote systems.