Skip to Content
Technical Articles
Author's profile photo sachin tripathi

Route incoming files based on filename

Hello Integration Folks,

In this blog post you will be knowing how to route files based on filenames.

Business Case: I had a requirement in my project to poll the files with different filenames from the same SFTP directory server via CPI and send it to 3rd party SFTP server.


Use router to route incoming files based on the filenames. For ex., SalesOrder2021_05_18T051632.csv , ScheduleOrder2021_05_18T041812, etc.

1. Create your iflow and configure your sender SFTP.

2. Connect Router in order to route the files.


3. Select expression type as Non-XML and provide conditions as :

${header.CamelFileName} regex ‘SalesOrder.*’ for first router

${header.CamelFileName} regex ‘ScheduledOrder.*’ for second router

and keep last router as default route.

-> ${header.CamelFileName} regex ‘x.*’ means it will route all the messages that have a filename starting with x.

For more information on usage of non-xml conditions, click here.

Conclusion: You will now be able to route incoming files to different routes based on filename and can perform modifications/ transformations as required.

I am new to CPI, please keep supporting and suggest improvements.

Happy learning !!!

Thanks & regards,

Sachin Tripathi

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo d jaiswal
      d jaiswal

      Good information 🙂

      Author's profile photo sachin tripathi
      sachin tripathi
      Blog Post Author

      Thank you 🙂 Deepak Jaiswal