What to do if variable substitution causes multiple files to go to a single file name

For Managed File Transfer, if you are monitoring a directory and transferring multiple files from a source to a destination location and you are using ${FileName} variable substitution, you must test the variable substitution results. The results need to be tested because the use of variable substitution might cause unexpected combinations of file transfer commands to be invoked.

To determine whether the problem is occurring, look for cases of multiple files appearing to transfer but only one file arriving at the destination. You might see errors in the file transfer log showing multiple files attempting to transfer to the same destination file name and failing transfers to the same file name.

Why this problem occurs

When multiple files are being processed by an MFT directory monitor, the Task xml runs for every file that the monitor finds in the directory being monitored. If the ${FileName} is only specified in the destination of the xml task file and not the source, the transfer is invoked for each file multiple times, once for each file name combination.

For example:
<source disposition="delete" recursive="false">
    <file>e:\temp</file>
</source>
<destination exist="overwrite" type="file">
   <file>s:\outdir\${FileName}</file>
</destination>

Avoiding this problem

If you are using ${FileName} variable substitution in the source or destination and are expecting a variation of the same file name to arrive at the destination, be sure to specify ${FileName} in BOTH the source and destination of your task XML definition.

The following example takes a file from e:\temp\<filename> and transfers it to s:\outdir\<filename>.out:
<source disposition="delete" recursive="false">
      <file>e:\temp\${FileName}</file>
  </source>
  <destination exist="overwrite" type="file">
     <file>s:\outdir\${FileName}.out</file>
  </destination>