How to Copy Files to Multiple Destinations with Diplomat MFT Enterprise Edition

This tech tip explains how to copy files brought in by Diplomat MFT Enterprise Edition to multiple destinations on the local network using a batch file that runs at the end of the file transfer job.

STEP 1: Create a batch file to copy the files using the following as an example:

echo off
setlocal EnableDelayedExpansion
rem This batch moves each of one or more files to one or more directories
rem The argument list is as follows:
rem arg1 - Base directory for the source files
rem arg2 thru argN+1 (where N is # files) are filepaths relative to arg1 -
rem each of these should be in double quotes
rem argN+2 is -d to signal the start of the directory list
rem argN+3 thru argN+2+D (where D is # directories) are fully qualified
rem paths of destination directories - each of these should be in
rem double quotes

rem grab the base directory
set basedir=%~1

rem this loop creates an array of source filepaths
set i=0
if %1 == -d goto done1
set /A i+=1
set files[!i!]=%~1
goto loop1
set numfiles=%i%

rem this loop creates an array of destination dirs
set i=0
if "%1"=="" goto done2
set /A i+=1
set dirs[!i!]=%~1
goto loop2
set numdirs=%i%

rem echo Files:
rem for /L %%i in (1,1,%numfiles%) do echo !files[%%i]!
rem echo Dirs:
rem for /L %%i in (1,1,%numdirs%) do echo !dirs[%%i]!

rem this double loop goes thru the files first and then the dirs
rem copying each file to each dir
for /L %%i in (1,1,%numfiles%) do (
for /L %%j in (1,1,%numdirs%) do (
set filepath=!basedir!!files[%%i]!
echo copying !filepath! to !dirs[%%j]!
copy /Y "!filepath!" "!dirs[%%j]!"

STEP 2:  Locate the Commands panel with a field named Execute After File Transfer Job at the bottom of the Diplomat MFT transaction screen.

commands panel

STEP 3:  Add the batch file to the file transfer job by entering the following command into the Execute After File Transfer Job field.

"C:multipleDestinations.bat" "C:destination" <DEST_FILE_LIST> -d
"C:destination_1" "C:destination_2" "C:destination_3"

The command parameters are:

  • “C:multipleDestinations.bat”, full path to the location of the batch file.
  • “C:destination”, full path to the destination directory containing the files written by the Diplomat file transfer job.
  • <DEST_FILE_LIST>, a Diplomat parameter containing the list of files written by the Diplomat file transfer job.
  • -d, signal to start list of directories where files will be copied.
  • “C:destination_1” to “C:destination_N”, full paths to each additional location where files will be copied.

STEP 4: Right-click on the transaction ID in the left nav and select Run Now  to execute a test job.

Test copying to multiple destinations