I think the easiest solution is probably to replace your writers with FeatureWriters. Connect all the summary ports to a FeatureHolder + Sampler (1st feature only) and then use the ZipArchiver from the FME Hub.
If you're not too comfortable programming in Python, this will make life much easier for you, especially in the long run (maintenance).
I think the easiest solution is probably to replace your writers with FeatureWriters. Connect all the summary ports to a FeatureHolder + Sampler (1st feature only) and then use the ZipArchiver from the FME Hub.
If you're not too comfortable programming in Python, this will make life much easier for you, especially in the long run (maintenance).
Great tip! But what if You need to delete all directories which were zipped after zipping process? Is there any way how to remove them please?
To delete a directory tree recursively, you can use the following in a PythonCaller:
import shutil
import fmeobjects
def delete_directories(feature):
directory_to_delete = feature.getAttribute('directory_to_delete')
if directory_to_delete:
shutil.rmtree(directory_to_delete)
You will have to provide a single feature with an attribute "directory_to_delete" containing the root of the folder structure to delete.
Example if you send a feature with the following attribute:
directory_to_delete = 'c:\output\temp123'
This will permanently delete ALL the files and subdirectories from c:\output\temp123 and down. Notice that the deleted files will NOT go to the recycle bin, they will be deleted for good. See also the documentation for rmtree.
NOTE: I assume no responsability whatsoever for the use or abuse of the above code! Be careful, you're on your own if something important gets deleted!
To delete a directory tree recursively, you can use the following in a PythonCaller:
import shutil
import fmeobjects
def delete_directories(feature):
directory_to_delete = feature.getAttribute('directory_to_delete')
if directory_to_delete:
shutil.rmtree(directory_to_delete)
You will have to provide a single feature with an attribute "directory_to_delete" containing the root of the folder structure to delete.
Example if you send a feature with the following attribute:
directory_to_delete = 'c:\output\temp123'
This will permanently delete ALL the files and subdirectories from c:\output\temp123 and down. Notice that the deleted files will NOT go to the recycle bin, they will be deleted for good. See also the documentation for rmtree.
NOTE: I assume no responsability whatsoever for the use or abuse of the above code! Be careful, you're on your own if something important gets deleted!
Brillant! I have tested your code and it is completely what I have search!
Thank you @david_r once again!