colinam1992
colinam1992

Reputation: 338

CFZip of certain file type

Is it possible to use cfzip to create a zip folder containing of a certain type. I need to do this to take out .bak files from a folder with different filetypes and insert them into a zip folder.

Thanks

Colin

Upvotes: 0

Views: 409

Answers (1)

Keshav jha
Keshav jha

Reputation: 1364

Steve already pointed you to the CF documentation which has example of delete. To create a zip, the simplest way is as follows:

<cfset fileName = createUUID() />
<cfzip file="D:\#fileName#.zip" action="zip" 
       source="D:\myfolder" 
       filter="*.bak" 
       recurse="No" >

If you want to add the files of a sub-directory, then make recurse="yes". To filter multiple file types you can simply use comma separated file type in filter like this filter="*.jpg, *.gif, *.png"

Note: I have used dynamic file name in case you want to run this script multiple times and have different file name, or multiple users are accessing this script at the same time.

Upvotes: 1

Related Questions