Skip to Content

Move original file to another folder on SFTP server in case of exception

Hi all,

In CPI we connect to an SFTP environment with folders input, output and error. The files needed processing are set in the input folder and upon succesful processing we replace them to the output folder. However, in case of an exception we would like move the file to the error folder.

My question is whether this is possible: the SFTP adapter only has a post-processing action and lacks a post-exception action.

The only solution I can come up with is to load the file with a separate flow in a datastore,remove it from the input folder and output it again based on the processing results. But I'd rather move the original file so that the system behind the SFTP environment can check that there is a locked file in the input folder.

Thanks for helping out!


Add comment
10|10000 characters needed characters exceeded

3 Answers

  • Best Answer
    Posted on Jul 29, 2019 at 10:18 AM

    The path where file is moved Post-Processing can have dynamic constituents. Using this you can determine where file is moved based on property, let's call the property "archiveDirectory". You can set property "archiveDirectory" initially for successful processing to 'output'. For failed processing, set the property "archiveDirectory" in Exception Subprocess ending with Message End.

    Your path to move the file post processing could be \${property.archiveDirectory}\${file:name}.

    The solution is explained in the blog: Dynamic Setting of Archive Directory for Post Processing in SFTP Sender Adapter

    Hope it helps,


    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 18, 2019 at 03:18 PM

    Hello Bram,

    Below might help you.

    1) Copy the content of file and file into Properties ( Say P_FileContent and P_FileName).

    2) In case of exception use Send Step inside Exception with SFTP receiver adapter and set the file name & filecontent stored in property.


    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Sriprasad,

      The problem then is that the file is still in the input folder as well, while I would like it to be only in the error folder.

      So I think in this case the datastore operation is best then, since you cannot delete files with the SFTP adater (only after processing).



  • Posted on Jul 18, 2019 at 02:39 PM

    Hi Bram,

    Did you figure this out? I have the same requirement and am looking at some different options. I would love to know what your solution was. I believe the delete can be done using a Groovy script but am wondering if there is another way or design that would accomplish this.

    Thank you,

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Doug,

      Only for the separate IFlow scenario: so first pick up + delete file, then process and push file accordingly.

      I think there no other option with current SFTP adapter than this.