#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    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.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,243
    Rep Power
    967
    Yes, you can use a directory as the source and specify a filter.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0
    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.
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,243
    Rep Power
    967
    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).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0
    Thanks, I did find it much faster to copy the files to a temp directory rather than calling cfzip 100+ times in a loop.

    Appreciate it!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    1
    Rep Power
    0
    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.

IMN logo majestic logo threadwatch logo seochat tools logo