To extract a zip file in ColdFusion we have a wonderful tag "cfzip". By, using which we can list the files available in that zip or we can give password for password encrypted zip to extract all files.
Sometimes we need to extract only 1/2 files from the zip bundles then how can we extract only the required files using cfzip.
<cfzip action="unzip" file="#local.inFilePath#" destination="#local.outputPath#" recurse="true" filter="#local.fileList.name#" overwrite="true">
file: Takes the input zip file.
destination: It's the destination directory in which you want to extract the files.
recurse: Specifies whether action applies to sub directories in the zip bundle.
overwrite: If a file exists with the same name in the destination directory then it will overwrite.
filter:Filter the files which you need to extract.
Case 1: Extract All text files from the zip bundle
filter = "*.txt";
Case 2: Extract a specific file(xyz.jpg) from the zip bundle
filter = "xyz.jpg";
Case 3: Extract all files whose file name contains string "listing"
filter = "*listing*.txt"
Case 4: Extract more than one files with specific file names
filter = "abc.txt|xyz.txt". It will extract only abc.txt and xyz.txt
The filter is applicable to the following actions of "cfzip"
Hope it will help you...