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 name of a zip archive file; 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. Any folder specified must actually exist. You may pass an empty string but you may not simply omit the [ path ] argument. The current working folder is assumed if an empty string is specified.

 

[ file ]

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

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 internal script variable contains the total number of files unzipped by this command.

 

Consider the following example which passes an empty string to the [ path ] argument so the file will be extracted to Robo-FTP’s current local 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

 

Note: When the TMPFILE command is active, the output [ file ] created by this command will have a different name until the extraction process is successfully completed.

 

 

Related command(s): ZIP, PGPENCRYPT, PGPDECRYPT, TMPNAME

See also: Data Compression