Restore the Case Organizer

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

  • FileSystem object

Code

ct = 0
subpos = 0
subfound = 0
'Use as a flag to see if the Case Org has been restored
bRestored = "No"   
sCaseOrgDir = CaseDir() & "profiles\all users\CaseOrg"
sCaseOrgBkupsDir = CaseDir() & "profiles\all users\CaseOrgBkUps"

'Create File System Objects and assign those objects to variables
Set fso = CreateObject("Scripting.FileSystemObject")
Set CsOrgBkps = fso.getfolder(CaseDir() & "profiles\all users\CaseOrgBkUps\")
Set Subs = CsOrgBkps.subfolders

Do
   'Get the preferred Backup from the user
   sDate = AskEntry("Type in the date from which you wish to restore the Case Organizer" _
  & vbCrLf & "Use M/D/YY format","Restore Case Organizer")
   'Will end the loop (and script) if the user has left the entry box blank or clicked Cancel
   If sDate = "" Then  
      Exit Do    
   End If

   'Checks to see if user input is a date or a foldername
   If InStr(sDate, "/") Then  
      'If the users has entered a date, replace the slashes to make the folder name valid
      sFolderDate = Replace(sDate, "/", "")   
      'Check to see if the folder exists
      bExists = fso.FolderExists(sCaseOrgBkupsDir & "\" & sFolderDate) 

      If bExists Then    
         'If it exists, see If there are multiple folders For that Date.
         If Subs.count > 1 Then  
            'Cycle through subfolders and see if the modified date string (no slashes) is
            'present in the subfolder name 
            For Each SF in Subs  
               nm = SF.name     
               SubPos = InStr(nm, sFolderDate)
           'If it is present SubPos will reflect the position found, if it is greater than 0                                                 'then the string was found
               If SubPos > 0 Then  
                  'Add one to our variable to keep track of how many subfolders have that string                    
                  subfound = subfound + 1  
               End If
            Next

            ' If there is more than one folder containing that string then ask what the
            'user wants to backup
            If subfound > 1 Then     
               bRest = AskYesNo("There is more than one backup for " & sDate & ", would"_
               & "you like to restore the most recent?")
               'If the users clicked yes, will restore the most recent backup based
               'on the date created
               If bRest = -1 Then 
                  'Compares the files that contain the specified date string to find the most recent    
                  sLatestFold = CompareFiles(sFolderDate)
                  'Copies the second folder over the first and names it the third argument   
                  Call CopyOver(sCaseOrgDir, sCaseOrgBkupsDir & "\" & sLatestFold, "CaseOrg") 
                  'Flags the CsOrg as restored
                  bRestored =  ""
                  'Alerts the users that it has been restored from the specified date                 
                  msg "Case Organizer Restored from " & sDate        
               Else
                  'Instructs the user on what to do if they wish to restore by foldername
                  'And begins the Loop so they may enter a foldername
                  msg "Enter the folder name that you want to restore"  
               End If
            'If there isn't more than one folder containing that date string, restore the one found
            Else     
               'Copies the second folder over the first and names it the third argument     
               Call CopyOver(sCaseOrgDir, sCaseOrgBkupsDir & "\" & sFolderDate, "CaseOrg") 
               'Flags that the CaseOrg has been restored to break the loop
               bRestored = ""  
               'Alerts the users that it has been restored from the specified date     
               msg "Case Organizer Restored from " & sDate   
            End If
         End If
      'If the folder cannot be found - gives the users information on how the date
      'they provided might be off  
      Else
         msg "There is no backup created on " & sDate & vbCrLf &"If this date is correct, "_
            & "you may have entered the Date in MM/DD/YY format." & vbCrLf &  "Do not" _
            & " use zeros to round out the Month And day numbers"
      End If
   'The user didn't enter a date, entered a foldername
   Else   
      'Checks to see if the folder the users entered exists        
      bExists = fso.FolderExists(sCaseOrgBkupsDir & "\" & sDate) 
      'If it does, we just take their word for it that that's the one they want and restore it
      If bExists Then       
         Call CopyOver(sCaseOrgDir, sCaseOrgBkupsDir & "\" & sDate, "CaseOrg")
         'Flags that the CaseOrg has been restored to break the loop
         bRestored = ""       
         msg "Case Organizer Restored from " & sDate
      Else
         msg "That folder cannot be found"
      End If 
   End If
'Loops to give the user opportunity to get the right date/folder name
Loop While bRestored = "No"   
Function CompareFiles(ModDate)
'Compares the system date created attribute of the files containing the specified string and
'assigns the most recent filename to the variable Latest
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set CsOrgBkps = fso.getfolder(CaseDir() & "profiles\all users\CaseOrgBkUps\")
   Set Subs = CsOrgBkps.subfolders
   iteration = 0   'Resets the variables to 0
   Latest = 0
   Current = 0
  
   'Cycles through the subfolders
   For Each S1 in Subs 
      'assigns the folder name to a variable  
      FoldNm = s1.name 
      'Looks for the user specified date string in the foldername  
      found = InStr(FoldNm, ModDate) 
      'If the date string is found,
      If found > 0 Then
         'Get the date created
         Current = s1.datecreated 
         'Check to see which folder was more recently created 
         LatestDate = DateCheck(Current) 
         If LatestDate = Current Then
            'If saves the folder name of the most recent folder   
            LatestName = s1.name  
         End If
      Else
            msg "There was a problem finding the requested folder, please try again"
      End If
   Next
   'Returns the folder name to the main script
   CompareFiles = LatestName      
End Function

Function DateCheck(Current)
   'Compares the dates created if date1 is more recent than date 2,
   'DateDuff will return a negative number
   Difference = DateDiff("s", Current, Latest) 
   If Difference < 0 Then 
      'Reassigns so that the most recent is assigned to the Latest variable      
      Latest = Current        
   End If
   'Returns the date to the CompareFiles function
   DateCheck = Latest       
End Function

Function CopyOver(ToFolderPath, FromFolderPath, ExName)
   'Copies the second folder over the first
  
   'Gets the length  of the path to be copied to
   ToPathLen = Len(ToFolderPath) 
   'Gets the length of the path to be copied from   
   FromPathLen = Len(FromFolderPath)  
   'Gets the position of the last slash so that the foldername can be extracted
   'from the string
   ToLastSlash = InStrRev(ToFolderPath, "\") 
   FromLastSlash = InStrRev(FromFolderPath, "\")
   'Strips the last folder from the path to be copied to so that the new folder
   'will not end up inside the existing one
   ToPath = Left(ToFolderPath, ToLastSlash - 1) 
   FromPath = Left(FromFolderPath, FromLastSlash - 1)
   'Gets the folder name to be copied to
   ToFolderName = Right(ToFolderPath, ToPathLen - ToLastSlash) 
   'Gets the folder name to be copied
   FromFolderName = Right(FromFolderPath, FromPathLen - FromLastSlash)

   'Creates a File System Object to handle the folder move and copy
   Set fso = CreateObject("Scripting.FileSystemObject") 
   'Checks to see if the folder to be overwritten actally exists  
   If fso.FolderExists(ToFolderPath) Then 
      'If it does, it gets deleted      
      fso.DeleteFolder(ToFolderPath)        
   End If

   'Copies the new folder into the old path (the True means it will overwrite any existing
   'folder with that name
   fso.CopyFolder FromFolderPath, ToPath & "\", True   
   'Sets the File System Object to the new placement of the new folder 
   Set fso = fso.GetFolder(ToPath & "\" & FromFolderName) 
   'Renames it to the specified name (The third argument passed in)
   fso.Name = ExName            

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.

Testimonials
"Nothing else has the features and functionality of AD Summation. iBlaze has the ability to cull 100,000 documents to what is responsive to an issue. We have attorneys on the road taking depositions around the United States, for sometimes up to two months. They are able to take more then 50,000 documents with them and prepare for the next deposition using AD Summation."
Whitney Summers, Burr Forman LLP
Case Studies
Today law firms are challenged like never before when faced with mega-sized cases involving millions of documents and millions of dollars. A multi-million document litigation will saddle a law firm with difficult technology decisions and staffing concerns. How does a law firm involved in a mega-sized case evaluate their document review options and determine the right database technology choice?