I need code that will delete all files within a folder that begin with a specific string, except for the most recent version.
For instance in folder C:\ I will have the following files:
In this example only files I would want anything beginning with "Test_" deleted except for the most recent version " C:\Test_01292010.zip". Thus C:\Test_01282010.zip, C:\Test_01272010.zip, C:\Test_01262010.zip would be deleted and the rest would be kept. How would I go about achieving this?
Thus far I've been using the code below to delete specific files.
Public Sub KillProperly(Killfile As String)
On Error Resume Next
If Len(Dir$(Killfile)) > 0 Then
SetAttr Killfile, vbNormal