How to retrieve specific files from an SFTP Server using a regex pattern

If you require to retrieve specific files based on the file name from an SFTP Server, please follow the below instructions:

Illustrated in the image below is an example of how a regex pattern is used in a flow to search for files with a specific name sequence using the SFTP List step as a source step and Action the files accordingly using the STPF Actions destination step.

The below image shows the list of files in the specified SFTP Server directory. In this example, the text files that start with the word “Report” are the files that will be retrieved/returned.

In the SFTP List source step, specify the Regex Pattern as highlighted in the below image.

The following is a breakdown of the regex pattern that was used:


* ^ - the beginning of the filename
* Report_ - the literal characters 'Report_'
* .* - any character repeated zero or more times
* \. - a single '.' character
* txt - the literal characters 'txt'
* $ - the end of the filename

The below image shows the configuration of the SFTP action step to copy the file to a new directory

For more information on regex patterns, please click on the link below:

RegExp - JavaScript | MDN

The below image shows the output of the files that are returned by the SFTP List source step.