Skip to main content

I have a workspace which goes off to the www to download a file for processing further along the workbench. Once the task has completed how can i automate deleting all contents of the specified folder. I am aware of directory watch to do something when a folder is modified or deleted, but i just want to delete the contents.....

Different options:

  • SystemCaller and commandline like DEL or RM.
  • PythonCaller and Python.
  • FileCopyWriter, I have seen a post on the forums where someone used the FileCopyWriter to delete folders or files, not sure how.

 

As an alternative you can download your files to a temp folder created by the TempPathnameCreator. This is what I use if possible.


Maybe other people have some other ideas but I generally use or the SystemCaller to do some command line things or the PythonCaller with a script. I like the PythonCaller better because I find it easier to check for problems with the directory path I am using to clear of files.


My personal "best practice" is to always use the temporary folder given by the TempPathnameCreator transformer. This folder is guaranteed to be unique every time and is automatically deleted by your OS once the workspace completes.


For me, TempPathnameCreator would be the way to go.

Start with a Creator, followed with a TempPathnameCreator, a HttpCaller to download your data (save as set in the TempPathnameCreator), and finally use a FeatureReader to actually import the data.

No need to worry about removing your download later.

TempFileCreator


For me, TempPathnameCreator would be the way to go.

Start with a Creator, followed with a TempPathnameCreator, a HttpCaller to download your data (save as set in the TempPathnameCreator), and finally use a FeatureReader to actually import the data.

No need to worry about removing your download later.

TempFileCreator

Thanks very much for all the suggestions, I will give it a go and certainly look at the TempPathnameCreator

 


Reply