This tech tip explains how to unzip files brought in by Diplomat MFT Enterprise Edition using a batch file that runs at the end of the file transfer job.
STEP 1: Create a batch file to unzip the files using the following as an example. The lines in red typeface may need to be modified depending on the software used to unzip files.
echo off setlocal EnableDelayedExpansion rem This batch file unzips each of one or more files to one or more directories rem The argument list is as follows: rem arg1 - Base dirctory 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 :loop1 shift if %1 == -d goto done1 set /A i+=1 set files[!i!]=%~1 goto loop1 :done1 set numfiles=%i% rem this loop creates an array of destination dirs set i=0 :loop2 shift if "%1"=="" goto done2 set /A i+=1 set dirs[!i!]=%~1 goto loop2 :done2 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 unzipping 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]! rem the next line is an example of how to unzip with 7-Zip "C:\Program Files\7-Zip\7z.exe" e -y "!filepath!" "-o!dirs[%%j]!" rem the next line is an example of how to unzip with WinZip rem "C:\Program Files\winzip\wzzip.exe" -e -o "!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.
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:\unzipFiles.bat" "C:\destination" <DEST_FILE_LIST> -d "C:\destination_1" "C:\destination_2" "C:\destination_3"
The command parameters are:
- “C:\unzipfiles.bat”, full path to the location of the batch file.
- “C:\destination”, full path to the destination directory containing the zip 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 unzipped.
- “C:\destination_1” to “C:\destination_N”, full paths to each location where files will be unzipped.
STEP 4: Right-click on the transaction ID in the left nav and select Run Now to execute a test job.