Solved

How can i automate the deletion of a folder???

  • 9 March 2022
  • 5 replies
  • 70 views

Badge +9

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.....

icon

Best answer by geomancer 9 March 2022, 15:15

View original

5 replies

Userlevel 6
Badge +31

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.

Badge +7

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.

Userlevel 4

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.

Userlevel 3
Badge +33

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

Badge +9

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