Blog

Posts Tagged GFI MAX

Cleanup Site Concentrator

Hey Guys,

I’ve had a number of site concentrators not clearing the cache properly.
According to http://www.allthingsmax.com/2011/12/saving-time-headaches-by-saving.html,

The Site Concentrator is self-cleaning, so in 30 days or less after download, the patches, etc. will be removed from the cache path automatically.

I have not found this to be the case, so have had to write a script to do it for me.
Paremeters to be passed are:
/ConcentratorPath: for where the cache Directory is located.
/ReportOnly: if you want to see how many files are over 30 days without deleting them.

Parameter Example:
/ConcentratorPath:”c:\UpdateCache” /ReportOnly:true

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Option Explicit  
Dim FSO, Folder, File, DateRange, CurrentFolder, TotalSize, FileSize, Path, bDebug, ReportOnly
 
Set FSO = CreateObject("Scripting.FileSystemObject") 
 
Path = WScript.Arguments.Named("ConcentratorPath")
ReportOnly = WScript.Arguments.Named("ReportOnly")
 
If FSO.FolderExists(Path) = false Then
	WScript.echo "Concentrator Path not found."
	WScript.Quit(1)
End If
 
If lcase(ReportOnly) = "true" Then 
	bDebug = true
	if bDebug = true Then WScript.echo "*** No Files Deleted, ReportOnly Enabled ***"
End If 
 
DateRange = dateadd("d", -30, Now)
ProcessDirectory(Path) 
 
If TotalSize = 0 then
	WScript.echo "No Old Updates Found."
ElseIf TotalSize > 1024 then
	TotalSize = TotalSize / 1024
	WScript.echo "Total Size: " & FormatNumber(int(TotalSize * 100) / 100, 2) & "Gb"
Else
	WScript.echo "Total Size: " & FormatNumber(int(TotalSize * 100) / 100, 2) & "Mb"
End If
 
if bDebug = true Then WScript.echo "*** No Files Deleted, ReportOnly Enabled ***"
WScript.Quit(0)
 
Sub ProcessDirectory(Directory)
Set CurrentFolder = FSO.GetFolder(Directory) 
 
For Each File in CurrentFolder.Files
	If File.DateLastModified < DateRange then
		FileSize = File.Size / 1024 / 1024
		WScript.Echo File.Name & " last modified at " & File.DateLastModified
		WScript.Echo "File Size: " & FormatNumber(int(FileSize * 100) / 100, 2) & "Mb"
 
		If bDebug = false Then 
			On Error Resume Next 'Dirty Error Handleing :)
			File.Delete
			On Error goto 0
		End if
 
		TotalSize = TotalSize + FileSize
	End if
Next
 
For Each Folder in CurrentFolder.Subfolders
	ProcessDirectory(Directory & Folder.Name)
Next
 
End Sub

Posted in: Scripts

Leave a Comment (0) →