1. Home
  2. Administration
  3. How can I gunzip a single file (without TAR)?

How can I gunzip a single file (without TAR)?


In Diplomat MFT Enterprise edition, you have the option to ZIP (outbound) or UNZIP (inbound) files as part of a transaction. The ZIP/UNZIP operations support both ZIP and TAR + GZIP formats. But what if you need to unzip files that are individually compressed as GZIP files? That requires a bit of special handling.

GUNZIP Indiviual files

When individual files are compressed with gzip, they typically end in a “.gz” extension. These files cannot use the in-built “gzip” feature of Diplomat MFT, because that operation assumes that a collection of files have been tarballed (.tar) first, then gzip compressed (.tgz, or .tar.gz, or sometimes just .gz). If you know that the incoming files for an inbound job have been individually compressed using GZIP, you will need to execute a post transaction execution command.

Below we will demonstrate how you can achieve this by using the free software “7-Zip”, which is available at www.7-zip.org. Other command line clients could be used as well.

The basic steps will be:
1. Download and install 7-zip
2. Create a batch file to be used by Diplomat MFT
3. Configure your Post Transaction command to use the batch file

7-Zip Batch File:

Create a batch file with the following contents. Simply copy + paste the batch file below into Notepad (or similar text editor), and save in a location that is accessible to the Diplomat MFT service. We recommend `c:\programdata\coviant software\diplomat-j`. Note that the batch file below assumes that 7-zip is installed in the default location, c:\program files\7-zip.

@echo DestFolder is '%DESTFOLDER%'
@echo Our input file is '%THEFILE%'
for %%f in (%THEFILE%) do set OUTPATH=%%~dpf
@echo Our output path is '%OUTPATH%'
@echo "c:\program files\7-zip\7z.exe" e  -bb0 -tgzip -o"%OUTPATH%" %THEFILE% -and- del %THEFILE%
"c:\program files\7-zip\7z.exe" e -y -bb0 -tgzip -o"%OUTPATH%" %THEFILE% & del %THEFILE%
IF "%~2%"=="" (goto TheEnd) else (goto FilesLoop)

For the remainder of this article, we assume the above batch file is called ungzip.cmd and is stored in c:\programdata\coviant software\diplomat-j.

Post-Transaction Command

Configure your inbound transaction like normal, pulling down GZIP compressed files into the desired destination.

In the “Post-Job Process” area, in the “Custom Process” panel, supply these parameters:

Execute After File Transfer Job:  
C:\ProgramData\Coviant Software\Diplomat-j\ungzip.cmd “C:\ProgramData\Coviant Software\destination_location” <DEST_FILE_LIST>

The green highlighted text is the destination folder where the downloaded GZ files are placed by the Diplomat job.  In other words, the destination location for the inbound job. The “<DEST_FILE_LIST>” should be typed in exactly that way — it is a variable that will be replaced by a space separated list of file names that have been downloaded by the inbound job.

Working Directory:  C:\ProgramData\Coviant Software\Diplomat-j

This should be the same path that you used in the prior box — it is where the ungzip.cmd file resides.

Execute custom post-process on file transfer job failure:   Leave this unchecked, unless you have specific business requirements to do so.

Timeout:  I set this to 15 seconds, that seems long enough to unzip all the files.  Adjust to your situation.

Here is what the dialog box will look like:

Updated on April 21, 2022

Was this article helpful?

Related Articles