Inside SFMC, there are two different ‘types’ of automations you can make inside of Automation Studio. They are the Scheduled Automation and the File Drop Automation. For this article, we are going to be concentrating on File Drop Automations and the crazy Substitution Strings they can use as documentation on these automations is fairly vague and limited.

File Drop Automations

These automations are ‘triggered’ automations that read off of a file being loaded onto the SFMC FTP. They used to be called “Triggered Automations”. This type of automation is used for when you need immediate actions completed based on file being loaded to the FTP.

As a note though, this will only read off of the Salesforce Marketing Cloud FTP and will not work with 3rd party FTPs. There are a few considerations you should be aware of when dealing with File Drop Automations:

  • Your account needs to use the Enhanced FTP in order to use File Drop Automations
  • File Drop Automations will only work on the SFMC Enhanced FTP and not 3rd party FTPs
  • It is not recommended to use the Import or Export folders for this activity, but to instead create custom subdirectories for these automations
  • Changing the file name on the FTP or things such as File Transfers from Safehouse, etc. will not trigger the automation. Only uploads.
  • If you export a file via another automation to sit on the SFMC SFTP, a File Drop automation will NOT pick it up. (Thanks to James Lamb for the note on this)
  • Only 1 automation can run per file. You can have multiple automations running on a single folder, but they cannot be triggered off the same file.
  • There is no ‘run once’ option in File Drop Automations, it instead uses ‘Active’ and ‘Inactive’. This pauses the trigger or activates it to allow for editing without distortion of output. To ‘test the automation, you will need to drop a file while it is Active.

File Drop Trigger Options

These options allow you to choose how you want to have your automation triggered

  • You can set it to load specific filename patterns inside of a folder
  • Or set it to run on every file loaded into a specific folder
File Drop Automation Setup

Filename Patterns

This is used to set the filename ‘filter’ or naming convention to decide which files will trigger your automation. Files that meet the file name requirements (case insensitive) are processed as Automation Studio parses them. Meaning that as each file is loaded and read within the context of Automation Studios file parser.

NOTE: The Automation Engine will not include any file extensions (anything after the dot ‘.’ in the file name) so do not include this in your filter or it will fail

Filename Pattern

Operators available for Patterns:

Contains:
Similar to LIKE in SQL and just looks for if those characters exist in that order in any file. (e.g. LIKE '%FNP%')

Using pattern (contains bus) will succeed for:

  • Business.csv
  • omnibus.csv

Will fail for:

  • numb_us.csv
  • sub.csv

*Important note – using contains will not process the files in queue order but instead in what appears to be a random selection. This can lead to issues if dropping more than 1 file to the location meeting the pattern (Thanks to Michal Rzepka who runs sfmr.dev and Rafał Pawelec)


Begins With:
Similar to SQL LIKE with no wildcard at the front. (e.g. LIKE 'FNP%')

Using pattern (Begins with bus) will succeed for:

  • Business.csv
  • BUS.csv

Will fail for:

  • ebus.csv
  • getonmybus.csv

Ends With:
Reverse of Begins with. SQL LIKE with no wildcard at the end. (e.g. LIKE '%FNP')

Using pattern (Ends with bus) will succeed for:

  • omnibus.csv
  • trackingbus.csv

Will fail for:

  • business.csv
  • getonbusnow.csv

Note on Wildcards in Filename Patterns:
(Special thanks to Jason Cort and Christine Potochny for their conversation on Email-Geeks Slack channel about this)

Wildcards that are available inside of the Import Activities and File Transfer Activities are NOT available inside of the File Drop Filenaming Patterns. The field for File Drop automations is a literal string, meaning that if you type in myfile_%%month%% it will look for literally myfile_%%month%% and not myfile_01 like it would inside the import of file transfer activities.

There are no wildcards (that I am aware of) that work inside of this field, so you would need to account for this when setting up your naming convention. E.g. if your files begin with YYYYMMDD_myfile then you would need to do an ‘Ends With _myfile’ as the variable part is not definable inside the File Drop automation.

Multiple Filename Patterns on Same Folder

Special thanks to Shibu Abraham

I wanted to make a note on what would happen if you have 2 filename patterns on the same folder and the file dropped would match both patterns.

  • Only a single automation would be triggered, not both.
  • The filename pattern that is matched first is the one that would be triggered.

For example, say we have two filenaming patterns, CONTAINS Bootcamp and CONTAINS OrderDetails. These are both on the same folder. If we drop a file named Bootcamp_OrderDetails.csv. What would happen?

The answer is that the automation with the filename pattern of CONTAINS Bootcamp would be triggered and the other (CONTAINS OrderDetails) would be ignored despite matching on the file name because Bootcamp comes before OrderDetails. (Sample taken from Shibu’s video series on Automation Studio)

Folder (Directory) Trigger

If you set it to run on all files (no filename pattern), this will ‘lock’ that folder and will not allow any other file automations to select this folder. This reserves that folder to allow ANY file dropped into this folder will trigger your automation.

No Filename Pattern

File Queueing

File Queueing is set up to verify if you want to create a queue of multiple triggers if a second file is dropped before the first run is completed. You can also turn this off if you do not want the triggers to queue.

  • If you queue your runs, even if the previous run fails, it will still go through the queue until it is finished.
  • Queue will run through the triggers in the order they were triggered, but it will use the most recent files.
  • So if you overwrite a file in a filedrop for a later queued trigger, it will not use the original data, but the new data.
  • If you turn off queueing, any triggers that happen during a currently running instance will cause that instance to stop and restart based on the new file trigger.
File Drop File Queueing

Special thanks to James Lamb for this note:

If you are dropping a significant volume of files at a high frequency, there is a high chance that the SFMC Automation may choke on these files and potentially fail or process at a very slow rate.

If you are looking at a high volume and frequency, you may want to explore another option such as API or a consolidation of files outside of SFMC that are then dropped at a lower frequency to ensure SFMC can handle it and not fail or severely delay your process.

File Drop Substitution Strings

Inside File Drop Automations there are custom substitution strings (similar to Personalization Strings) that can be used in File Transfer Activities or Import Activities. These strings allow you to reuse the name of the file that triggered the automation (via Filename Pattern or folder drop) in your activities in subsequent steps inside the automation.

%%FILENAME_FROM_TRIGGER%%

This string will return the full filename of the file that triggered the automation. When using this string, you cannot add any prefixes, suffixes or file extensions without causing errors. This string includes the full filename at time of trigger, including the file extension.

NOTE: This can cause issues on large files, as the trigger could potentially begin before the file is finished loading on the FTP. This means that the file (myfile.csv) could be read and stored as (myfile.csv.p1) in the trigger as the FTP is still uploading it. This means that when the Import or File Transfer Activity tries to look for myfile.csv.p1 it will fail as that file no longer exists as the .p1 is now removed as the file is fully uploaded.

%%FILENAME_FROM_TRIGGER_BASE%%

This string returns the filename without the final file extension.You can use prefixes, suffixes and extension substitutions are allowed. If a file has more than 2 file extensions, this string will only remove the final one, not all those other than the first.

For example:

  • myfile.csv.zip.pgp will return myfile.csv.zip
  • myfile.csv.zip will return myfile.csv
%%BASEFILENAME_FROM_TRIGGER%%

This string will return the filename without any file extensions. Regardless of how many extensions are on the file, it will remove all of them. Prefixes, suffixes and extension substitutions are allowed.

For example:

  • myfile.csv.zip.pgp will return myfile
  • myfile.csv.zip will return myfile

NOTE: I usually recommend using this substitution string in your Imports and File Transfer Activities as it provides the safest output by just returning the name and none of the extensions, so you can easily just set the expected extensions inside of your filename pattern to ensure it is accurate.

DATE/TIME Substitution Strings

The Date and Time strings are fairly universal across most related activities in Automation Studio and File Naming Patterns in SFMC. The strings available are fairly self explanatory, but for a quick reference, I have listed them out below:

  • %%Year%%: four digit year (e.g. 2021)
  • %%Month%%: two digit month (e.g. 01)
  • %%Day%%: two digit day (e.g. 09)
  • %%Hour%%: two digit hour (e.g. 12)
  • %%Minute%%: two digit minute (e.g. 30)
  • %%Second%%: two digit second (e.g. 25)

NOTE: If you use the %%Second%% and %%Minute%% strings, this could lead to a ‘File Not Found’ error on large files due to the amount of time required to process those strings.

I hope this helps clarify a few things and helps put all of the information relating to File Drop Automations into a single spot instead of spread across multiple pages. Let me know if I missed anything or if you have anything you want to add!

Tags: , , , , , , , , , , , , , , , , , , , , ,
Subscribe
Notify of
guest
12 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
balbeer
balbeer
3 years ago

Thanks for this post. I have a question Can we use something like %%Day%% -1 just to read the file dropped a day before.

Thanks in advance.

Last edited 3 years ago by balbeer
Donatien Véron
Donatien Véron
2 years ago

Hello,

How to make an automation stops its execution in case of empty file (really empty or with only one header row) ?

Mathes
Mathes
Reply to  Donatien Véron
2 years ago

Add a Verification activity and if the DE count is not greater than 0, stop automation

Jon H
Jon H
2 years ago

Great info to have on file imports thanks, I was wondering if there is similar extensibility for naming ‘data extracts’ files beyond the wildcard specifiers (i.e. %%Year%%, %%Month%%, %%Day%%).

Last edited 2 years ago by Jon H
shankar
shankar
1 year ago

How can do a run once in file drop automation?

Carl
Carl
1 year ago

Is there any way to use the File Drop Substitution Strings within Script or other activities? I’m trying to grab the current file name and save it to a DE in order to track files that have been processed over time.

Santos
Santos
1 year ago

Hello!

Thanks for this post, but I have one question, when we have to reflect in the platform as soon as they happen subscriber updates such as unsubscribes, what it is better to use to achieve this in real time, APIs or File Drop automations?

Helo
Helo
1 year ago

Sorry, i’m new on Marketing Cloud and i can’t understant how this File Drop Substitution Strings works.
How this Strings can identificate the file?
In order for the file to be uploaded to Marketing Cloud don’t we need to put a file name that matches the source file?

Last edited 1 year ago by Helo
Priyanka Barick
Priyanka Barick
9 months ago

%%BASEFILENAME_FROM_TRIGGER%% is not working for me. It says file not found, any clue why this is not working in the import activity

Priyanka Barick
Priyanka Barick
Reply to  Priyanka Barick
9 months ago

I found the issue. Thanks anyways. This is is a great article!