VB Script to delete a set of files based on file extension

There might be an instance that you will have to delete all the test data files at the end of each performance test run so that a fresh set of test data files can be created for the next run. Instead of doing this manually at the end of each run use this simple macro do it automatically for you.

Const DeleteReadOnly = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.DeleteFile("C:\Users\XXXX\Desktop\SoapTextFiles\*.txt"), DeleteReadOnly

Change the destination folder in the above code and your macro is ready. 

"*.txt" defines that any file with .txt extension will be deleted. 

For deleting files of a different extension replace ".txt" with you desired file extension. Say for example ".xls" to delete excel files.