We have a requirement to delete all .xls file in a drive apart from certain file with name as Team.xls and Corporate.xls
I have got a script but this is creating all files. I am testing by creating a folder and creating several .xls file in that folder. The files with name Team.xls and Corporate.xls are also available. But this is deleting all files in that folder
==============================================================================
Dim fldPath, FSO, File, Folder, filExt
Set FSO = CreateObject("Scripting.FileSystemObject")
fldPath = "D:\Test_Delete"
Set Folder = FSO.GetFolder(fldPath)
For Each File In Folder.Files
If Right(File.name, 4) = "Team.xls" Or Right(File.name, 4) = "Corporate.xls" Then
Wscript.echo "Files Present"
Else
FSO.DeleteFile(fldPath & "\" & File.name)
End If
Next
MsgBox "Finished..."
===========================================================================