UNZIP Extract file(s) from a zip archive |
Top Previous Next |
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 .jpg and .jpeg 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" "" "*.jpg|*.jpeg"
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 |