Hopefully someone can assist me in trying to script the ffollowing.
I have a directory which is populated with files in the following format
EUN_XXXXXX_FULL.zip
EUN_XXXXXX_DELTA.zip
XXXXX is a number which increases with each file that is created. I need a method to move the files older than the last full to another folder, have tried to explain what I meant below.
EUN_XXXXXX_FULL.zip
EUN_XXXXXX_DELTA.zip
EUN_XXXXXX_DELTA.zip
EUN_XXXXXX_DELTA.zip
EUN_XXXXXX_FULL.zip - Deleted
EUN_XXXXXX_DELTA.zip - Deleted
EUN_XXXXXX_DELTA.zip - Deleted
EUN_XXXXXX_DELTA.zip - Deleted
So far have the following, but not sure how to search the files and delete the files after the 2nd FULL file.
Any suggestions?
I have a directory which is populated with files in the following format
EUN_XXXXXX_FULL.zip
EUN_XXXXXX_DELTA.zip
XXXXX is a number which increases with each file that is created. I need a method to move the files older than the last full to another folder, have tried to explain what I meant below.
EUN_XXXXXX_FULL.zip
EUN_XXXXXX_DELTA.zip
EUN_XXXXXX_DELTA.zip
EUN_XXXXXX_DELTA.zip
EUN_XXXXXX_FULL.zip - Deleted
EUN_XXXXXX_DELTA.zip - Deleted
EUN_XXXXXX_DELTA.zip - Deleted
EUN_XXXXXX_DELTA.zip - Deleted
So far have the following, but not sure how to search the files and delete the files after the 2nd FULL file.
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\MDS'} Where " _
& "ResultClass = CIM_DataFile")
Set objRegEx = CreateObject("VBScript.RegExp")
For Each objFile in colFiles
objRegEx.Global = True
objRegEx.Pattern = "\d{6}"
strSearchString = objFile.FileName
Set colMatches = objRegEx.Execute(strSearchString)
strFile = colMatches(0).Value
Next