This VBScript is designed to count and delete garbage files from a directory and its subdirectories. Garbage files are defined as those with “.tmp” or “.bak” extensions.
Download the Script: Download the cleanup.vbs
script file to your system.
Run the Script:
index.vbs
file.cscript index.vbs
.' Count garbage files
CountGarbageFiles objFSO.GetSpecialFolder(0) ' 0 represents the Desktop folder
This function counts the garbage files in the directory and its subdirectories.
' Call the function to search and delete garbage files
SearchAndDeleteGarbageFiles objFSO.GetSpecialFolder(0) ' 0 represents the Desktop folder
This function searches for and deletes garbage files from the directory and its subdirectories.
Function IsGarbageFile(objFile)
Dim extension
extension = LCase(objFSO.GetExtensionName(objFile.Path))
IsGarbageFile = (extension = "tmp" Or extension = "bak")
End Function
This auxiliary function determines if a file is garbage based on its extension.
You can customize this script by modifying the following parts:
tmp
and bak
) in the IsGarbageFile function.SearchAndDeleteGarbageFiles
function, such as deletion or logging.Thank you very much for helping in the project ❤