| Zip each file in a folder into its own archive |
| Date Updated - 07/22/2007 |
| Description User question: I would like to zip each file into its own archive. For example a folder contains 100's of .eps files each with a unique name of course. Example: B0123400ab.eps I would like to zip this into its own archive assuming the name of the original file with a .zip extension. Example: B0123400ab.zip I then need to have the original file deleted from the source directory. I then use the ftp task to send them to my customer. |
| Solution
1) Create an extra ZIP folder 2) Create a FileMonitor task: task Title = fileMonitor Dir to Monitor = your DATA folder (which has the .eps files) Filename = (leave blank) Criteria = Run task if file size > 0 Task To Run = None 3) Create a Zip task: taskTitle = zipTask Source Dir = DATA folder filename = $%fileMonitor::FileName%$ Dir to place zip archive = ZIP folder zip filename = $%fileMonitor::FileName%$.zip Your zip filename will be of the form: B0123400ab.eps.zip .There is no way around this. 4) Create a Delete task: taskTitle = deleteTask Source Dir = DATA folder filename = #$%fileMonitor::FileName%$ (the # is to ensure that an exact filename match is done) 5) Create a Chain: Step 1 = fileMonitor task option: if exit code = 0, go to step 100 (i.e. if no files exist, stop chain) Step 2 = Zip task option: if exit code > 0, go to step 100 (i.e do not run step 3 if zip fails) Step 3 = Delete task 6) You can schedule this chain to run every 1 minute or so (probably in a 2-4 hour range at night). Every time the chain runs, if a file is found, it will be zipped to the ZIP folder and deleted from the DATA folder. 7) You can then run a ftp task to ftp all files from the ZIP folder to your client. You can also clean up old files from the ZIP folder using a delete task which will delete all files from the ZIP folder. |