UNZIP        Extract file(s) from a zip archive

Top  Previous  Next

Syntax:

UNZIP

[ zip name ] [ path ] [ file ] [ /options ]

Arguments:

[ zip name ]

A variable or string defining the file name of the zip archive; if .zip extension is omitted, Robo-FTP adds it automatically; if no folder is specified, Robo-FTP creates or opens the archive in its working folder.

 

[ path ]

A variable or string defining the path to the target folder to where files are to be extracted; if no path name is specified, Robo-FTP uses the current working folder. If specified, this folder must exist.

 

[ file ]

A variable or string defining the file name(s) to be extracted.

Options:

/pw=xx

Define password used when the zip archive was created.

 

/skipexisting

Do not extract files from the archive that already exist in the target path.

 

/skipolder

Do not extract files from the archive that are older than, or have the same date and time as existing files in the target path.

 

/subdirs

Extract files with associated  folder names stored in the archive; this option must be selected if files are zipped into the archive using full path names (path information) are to be extracted.

 

 

This script command extracts file(s) from an existing zip archive file. Upon completion of the command, the %unzipcount script variable contains the total number of files unzipped by this command.

 

Consider the following example in which a single file is extracted to Robo-FTP’s working folder.

 

UNZIP "zipfile" "" "mydata.xml"

 

The example below extracts all the .xml files in the specified archive to Robo-FTP’s working folder. (Files saved with path information will not be extracted unless the /subdirs option is specified.)

 

UNZIP "zipfile" "" "*.xml"

 

The example below extracts all the .xml files in the specified archive to Robo-FTP’s working folder and into subfolders that may have been saved in the archive. Relative path names of any files found in the archive are restored.

 

UNZIP "zipfile" "" "*.xml" /subdirs

 

The example below extracts a file named index.html from a password protected archive and saves it in a target folder named c:\mysite.

 

UNZIP "zipfile" "c:\mysite" "index.html" /pw=mysecret

 

The example below extracts all newer files in the specified archive to the specified target folder.

 

UNZIP "c:\temp\archive.zip" "c:\my files" "*.*" /skipolder

 

If you have multiple file to unzip, the example below shows a loop that gathers zip files, one by one, from the current folder and extracts all files in the specified archive to the specified target folder.

 

:loop

GETNEXTFILE "*.zip" /timeout=10

;; branch if no more zip files

IFERROR $ERROR_WAIT_TIMED_OUT goto no_file

UNZIP %nextfile "c:\myfiles" "*.*"

GOTO loop

:no_file

 

Related Command(s): WORKINGDIR, ZIP