Delete folder using VBScript


A specific windows folder can be easily deleted with the "Delete Folder" action.

However, the above action does not support wildcard characters. This means that we cannot delete a folder that starts with/ends with/contains...etc some specific text.

In order to do so, we can use the "Run VBScript" action with the following configuration:

Dim FSO, Folder
set FSO=CreateObject("Scripting.FileSystemObject")

Note that this way, wildcards (*) are also supported, so if the name of the folder is for example "UniqueNameTodaysDate", the above command will still find and delete the folder.

Use cases

There are cases where each time an application runs, it will create a folder at a specific location with a unique name.

In order to delete that folder, we could implement a logic in our process to retrieve the subfolders of a folder and then check the names of those folder one by one.

The same functionality can be easily achieved with the above method.