Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to give inputs from a text file

Status
Not open for further replies.

dheerajreddy926

Programmer
Apr 15, 2012
10
EU
Hello All,

I am not a vb expert . I am planing to do an automation to delete log archives periodically from a location.we have around 100+ servers . I have got a VB script to delete folders based on path given .But i want the script to delete all archive folders in all servers . the path for Windows machines are \\srvrname\d$\sea77\siebsrvr\LOGARCHIVE and for AIX it is \\srvrname\Siebel\enterprises\siebel_aix\srvrname\logarchive.

Script i got for deleting logarchive for a particular server is
.............................................................
Const strPath = "D:\path"

Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")



Call Search (strPath)

WScript.Echo"Done."



Sub Search(str)

Dim objFolder, objSubFolder, objFile

Set objFolder = objFSO.GetFolder(str)

For Each objFile In objFolder.Files

If objFile.DateLastModified < (Now() - 3) Then

objFile.Delete(True)

End If

Next

For Each objSubFolder In objFolder.SubFolders

Search(objSubFolder.Path)

' Files have been deleted, now see if

' the folder is empty.

If (objSubFolder.Files.Count = 0) Then

objSubFolder.Delete True

End If

Next

End Sub

------------------------------------------------------------------
I want to schudule this job every midnight so that it clears logarchives in all servers which are 3 days old .


Thanks in advance!
Dheeraj.
 
The search function seems a little overkill. Why not...

Code:
set objFSO = CreateObject("Scripting.FileSystemObject")

function deleteArchive(strFolder)
   if (objFSO.FolderExists(strFolder)) then
      if (objFSO.GetFolder(strFolder).DateLastModified < (now - 3)) then
         objFSO.deleteFolder strFolder
      end if
   end if
end function

arrServers = an array of server names
foreach strServer in arrServers
   strServerPath = "\\" & strServer & \d$\sea77\siebsrvr\LOGARCHIVE"
   strAIXPath = "\\" & strServer & "\Siebel\enterprises\siebel_aix\srvrname\logarchive"
   deleteArchive strServerPath
   deleteArchive strAIXPath
next

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top