Vbs : delete all files with the same extension in a folder

The next two lines of code allow you to delete all files with a particular extension in a folder.

Set obj = CreateObject("Scripting.FileSystemObject")
obj.DeleteFile("C:\Windows\*.log")

The example below will delete all of the .log files from the C:\Windows folder.

Romain Drouche

Romain Drouche

Architecte Système | MCSE: Core Infrastructure

Expert en infrastructures IT avec plus de 15 ans d'expérience sur le terrain. Actuellement Chef de projet Systèmes et Réseaux et Référent SSI (Sécurité des Systèmes d'Information), je mets mon expertise au service de la fiabilité et de la sécurité des environnements technologiques.

GHinM▶