April 22nd, 2011, 03:15 PM
Pass a Directory Query to <cfzip>?
I'm cross-posting this from Stackoverflow because CF questions don't seem to be answered quite as often over there. I can't create a direct link to it because this is a brand new account, but I'd be happy to PM the URL to anyone who wants to see the question on SO. The following is a direct copy-paste from the question:
I need to zip files from a directory, but not all the files in the directory. I determine the files that need to be zipped by running a query on the directory listing.
Currently, I'm looping over the query results to add each file to the archive individually, but this can take a while in a large directory.
Is there any way to do this outside of a loop? I couldn't find anything in the CF docs that would indicate that you can pass some sort of list to cfzip.
April 22nd, 2011, 04:02 PM
Yes, you can use a directory as the source and specify a filter.
April 22nd, 2011, 06:56 PM
Sorry, I should have been more specific in my question. I need all files in the folder that have a last modified date greater than a date that I am passing as a parameter. Is that passable as a filter? It seemed like filters were for the purpose of zipping files with a specific naming convention or files of the same type.
April 23rd, 2011, 09:58 AM
You can specify a list of filter values, but if the list is very large that probably won't work. It might be worth seeing if it is faster to loop over the files and copy or temporarily move them to a temp folder, and then just zip the temp folder. Finally, move them back to their original location (if you didn't copy them).
April 24th, 2011, 11:40 PM
Thanks, I did find it much faster to copy the files to a temp directory rather than calling cfzip 100+ times in a loop.
Zhao compares China's social reality to an apple: it is much better, he says, to give the whole fruit to a foreigner when presenting China rather than just apple jam, juice or even vitamin C.
"Foreigners can bite and taste the apple by themselves, and it gives them room to digest and ponder it."
Zhao said he wants to explain and write on China in an easy and understandable way even high school students can get it. "Tell them ABC, not XYZ."
Over the past few decades, Zhao has left no stone unturned chumming up to foreign counterparts and impressing them with his soundbites.