Customizing Destination Path and Filenames
When setting up Destination filenames in Automations, you can include pattern characters that get substituted with values related to the Automation's run. The patterns below cover destination paths, trigger context, source paths, and time values.
Destination Path Related
For Copy or Move file Automations, the destination path determines where files are copied, moved, or created. The path can include formatting parameters that dynamically determine the destination at runtime.
Relative vs. Absolute Path
When a destination path starts with ./ or ../, it is treated as a relative path. In all other cases, it is interpreted as an absolute path.
Files vs. Folders
When a destination path ends with a /, it is recognized as a folder name, and the original filename is retained. When the destination path does not end with a /, the destination field serves as a replacement for the filename.
Trigger Related
These apply only if the Automation trigger is a File Action, and refer to the filename of the triggering File Action:
| Token Name | Description |
|---|---|
%tp | Entire path of triggering File |
%tf | Filename of triggering File (without folder name) |
%td | Folder name of triggering File (without file name) |
%tb | Filename of triggering File (without folder name and file extension) |
%te | Extension of triggering File |
For example, when the triggering file is at path/to/file.txt, the Automation destination path/to/dest/incoming-%tf resolves to path/to/dest/incoming-file.txt.
When the Automation trigger is an Inbound Webhook, any GET or POST parameters sent to that Webhook can be used by name. Parameters are limited to 190 characters each and 550 characters in total.
The pattern %u-[GET or POST Param name] is replaced by the value sent in that GET or POST parameter to the Inbound Webhook. For example, when the Inbound Webhook receives a parameter named username, the replacement pattern %u-username resolves to that value.
Source Path Related
These tokens apply based on the source path of the Automation. Source paths can include wildcard characters, and these tokens convert those wildcards in the source into meaningful values in the destination.
Two token families are available. %p tokens count folders from the matched file upward. %P tokens count folders from the root downward. Both work in destination folder paths and destination filenames, and you can mix them in the same destination.
| Token Name | Description |
|---|---|
%p1, %p2, %p3, ... | Folder name in the source path, counted upward from the matched file. %p1 is the matched file's parent folder. |
%P1, %P2, %P3, ... | Folder name in the source path, counted downward from the root. %P1 is the top-level folder. |
For example, when the source file is partner/app/team/inbound/file.txt, the destination archive/%P1/%P3/%P4/ resolves to archive/partner/team/inbound/.
Here is how that works. Each folder in the source path can be referenced from either direction:
| Folder | Top-down (%P) | Bottom-up (%p) |
|---|---|---|
partner | %P1 | %p4 |
app | %P2 | %p3 |
team | %P3 | %p2 |
inbound | %P4 | %p1 |
Build a destination by replacing folder names with the tokens you want. Using the same source file, the bottom-up destination archive/%p4/%p2/%p1/ resolves to the same folder, archive/partner/team/inbound/.
You can also mix token families in the same destination. For example, archive/%P1/%p1/ resolves to archive/partner/inbound/, anchoring the top-level folder while pulling the file's parent folder.
When To Use Each
Use %P when the folder you care about sits near the root and never moves, like a partner name, a department name, or a region.
Use %p when the folder you care about sits right above the file, like a date folder or a batch folder.
Mix both when you need to anchor to the root on one end and the deepest match on the other. For example, archive/%P1/%p1/ pulls the top-level folder and the file's parent folder into the same destination.
Time Related
These are always available and use the time associated with the run time of the automation. You can optionally choose the time zone used for calculating the date/time tokens in destination file or folder names. These values are similar to the values used by the strftime function in most standard code libraries.
| Token Name | Description |
|---|---|
%a | Abbreviated weekday name (eg Mon) |
%A | Full weekday name (eg. Monday) |
%b | Abbreviated month name (eg. Jan) |
%B | Full month name (eg. January) |
%C | Century number (the year divided by 100, range 00 to 99) |
%d | Day of the month (01 to 31) |
%e | Day of the month (1 to 31) |
%H | Hour, using a 24-hour clock (00 to 23) |
%I | Hour, using a 12-hour clock (01 to 12) |
%j | Day of the year (001 to 366) |
%m | Month (01 to 12) |
%M | Minute (00 to 59) |
%p | Either am or pm according to the given time value |
%r | Time in am and pm notation |
%R | Time in 24 hour notation |
%S | Second (00 to 59) |
%T | Current time, equal to %H:%M:%S |
%u | Weekday as a number (1 to 7), Monday is represented as 1. |
%U | Week number of the current year, starting with the first Sunday as the first day of the first week |
%V | The ISO 8601 week number of the current year (01 to 53), where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week |
%W | Week number of the current year, starting with the first Monday as the first day of the first week |
%w | Weekday as a number (0 to 6), Sunday is represented as 0. |
%y | Two-digit year without a century (range 00 to 99) |
%Y | Four-digit year including the century |
%Z | Time zone or name or abbreviation |
%% | A literal % character |
Find and Replace Text in File Names
For Copy or Move file Automations, you can search for specific text in the destination file name and replace it with your preferred text. For example, configure the Automation to find all destination file names containing the text Reviewed and replace it with the text Final. Any destination file name containing Reviewed (such as Invoice-Reviewed.pdf) is renamed to Invoice-Final.pdf. The search is case-sensitive, and wildcards are not supported.
The Text to find in file name and Replace with settings only replace one static text with another. You cannot substitute any time-related wildcard symbols using either field.
Overwriting Existing Files
For Copy or Move file Automations, you can specify to overwrite files if they already exist at the destination.
For the Copy file Automation type, enabling the above option provides a second option that lets you overwrite even when the file size is identical. This second option replaces existing files with newer copies, even when the file size of the newer copy is identical. We recommend only using this second option when needed, to avoid accidentally consuming unnecessary data transfer.
When overwriting a file on the destination path, the existing file is deleted first, then the new file is copied or moved to the destination. Both delete and create actions are logged.
Flatten Folders
For Copy or Move file Automations, you can specify whether to flatten the folder structure at the destination. When this option is enabled, the source folder structure is flattened at the destination, and all files from the source folder hierarchy are copied into the first level of the destination folder.
This is useful when copying or moving a large folder hierarchy to a single destination folder for backup or archival purposes. You can customize destination file names or specify which files can be overwritten in the destination folder for your workflow.