Overview
The Cleanup Case Organizer Backups script deletes the old backups created within the CaseOrgBkUps folder.
Description
This script uses the Microsoft Windows FileSystem object (an object-based tool for working with files and folders) extensively. It uses the FileSystem object to check for the presence of an existing CaseOrgBkups folder within the case’s \Profiles\AllUsers directory. It also uses the FileSystem object to delete the directories within the CaseOrgBkups folder created prior to a specific user specified date.
Collections / Objects / Methods / Properties
Code
CsOrgBkups = CaseDir() & "Profiles\All Users\CaseOrgBkUps"
Set fso = CreateObject("Scripting.FileSystemObject")
'If there are any backups for the Case organizer for this case, the prompt the user for a date
If fso.FolderExists(CsOrgBkups) Then
CleanDate = AskEntry("Please enter a cutoff date. All backups prior to this date will be"_
& "deleted", "Clean CaseOrgBkups Folder")
'If the user entered a date then call the CleanDirByDate function
If CleanDate<>"" And InStr(CleanDate, "/") Then
Call CleanDirByDate(CsOrgBkups, CleanDate)
Else
If CleanDate<>"" And Not InStr(CleanDate, "/") Then
msg "You must enter a valid date"
End If
End If
Else
msg "You don't have any backups of the Case Organizer to clean."
End If
Function CleanDirByDate(Dir, CleanDate)
'This function cleans out the specified Dir of subfolders that were created prior to the
'specified date
'Converts the user entered date string into a date type format
FormatDateTime(CleanDate)
Set fso = CreateObject("Scripting.FileSystemObject")
'Checks To make sure the specified Dir exists
If fso.FolderExists(Dir) Then
'If it does, create a file system object to work with the folder and its contents
Set fsoDir = fso.GetFolder(Dir)
Set Subs = fsoDir.Subfolders
'Cycle through each of the subfolder
For Each S1 in Subs
'Assign the subfoldername and the date created to variables
nm = S1.name
CheckDate = S1.DateCreated
'Assigns the date to a variable and sets the date format to be
'the same format as the user entered date string was converted to
CheckDate = FormatDateTime(CheckDate, 2)
'Gets the difference between the 2 dates,
'If the first date is more recent than the second it will assign a negative number
Diff = DateDiff("d", CleanDate, CheckDate)
'The current subfolder is not as recent as the CleanDate and is deleted
If Diff < 0 Then
fso.deletefolder(Dir & "\" & nm)
End If
Next
End If
End Function
Download File (zipped)
(right click on file and select 'Save Target As...')
NOTICE: This script is provided to you “As is” for use only with a valid CT Summation Enterprise or CT Summation LG family (iBlaze) license, pursuant to the terms of the license. Technical support is not provided for scripts under the CT Summation maintenance agreement or otherwise. The Limitation of Warranties and Liability provisions contained in the license accompanying the CT Summation program with which this script is run shall apply to use of this script with said program.