Toad World® Forums

Delete multiple files in Toad for Data Analysts Automation script


#1

Does any one know if it is possible to use the “Delete File” in an automation script to delete multiple files in a folder?

I have create an automation script that generates numbered PDF file for order confirmation notes for that days orders

Ie Order1.pdf, Order2.pfd

The PDF’s are placed into a folder, the folder is then zipped and emailed.

This works fine but I have a problem when the script runs on the next day and generates a new set of PDF files then the files from the previous day are still in the folder which get zipped.

Is there are way to delete multiple files using a wildcard character?

I can use the “Delete File” to delete a single named file but not multiples.

Any suggestions would be most useful


#2

Unfortunately, there is no direct way to submit wildcard character in the file name for the delete file activity. But if you’re working with TDA 3.0, there is a workaround. To use * in the delete file activity in TDA 3.0, you should use the “old” way of submitting activity properties:

  1. Double-click delete file activity in the designer. On the right-hand side you’ll see a property grid.
  2. Select Files property in the Misc section of it and click the button to the right from (Collection) text.
  3. In the FileDescription Collection Editor click Add button, new FileName description will be added to the FileDescription properties pane.
  4. Select FileName property in that pane and open a dropdown - standard Open File dialog will be displayed.
  5. Select ANY file in the directory containing your pdf files you’ll want to delete and close the dialog. Now you can manually edit FileName property, replacing filename part with something like *.pdf. Close FileDescription Collection Editor. You’re all set.

Of course, you can omit steps 4 and 5 and manually add full file name here instead (e.g., c:\temp*.pdf).

We’re working on bringing wildcard characters support in delete files activity.

Igor.


#3

Thanks for the suggestion

I tried this but when running my script get the following message in the script log

Could not delete C:\Toad_Scripts\To_Send*.pdf. File not found.
Could not delete . File not found

If it can not be done then I will have to look for an alternative solution.

Thank you anyway


#4

What version are you using? The suggestion was for 3.0.1. Are you using the latest version?

Debbie


#5

Still running V2.6

Upgrading to V3 is one of the thing on my to do list

Thanks anyway.


#6

Hi

Just wondering if this is possible using Toad Data Point - i’m hoping to be able to delete everything in a specified folder. Alternatively, i want to delete the latest file in that specified folder.

I have tried the steps above but can’t get it to work.

Thanks


#7

The above instructions by Igor still work. The UI was never changed.


#8

I’ve solved this in the past by simply creating a batch file and using the Run Program feature to call it - an extra step admittedly but does the trick