Overview
The ImageVerify script generates a report of the current case’s missing image files.
Description
This script uses Microsoft's ADO Data Control to read the current case’s Image Information table and Microsoft Windows FileSystem object (an object-based tool for working with files and folders) to detect if any listed image file is missing from the file system. The script includes extensive Image Information IMGFiles column parsing to convert CT Summation Image Information table syntax to Windows filepath. The script then uses the FileSystem object to write its findings to disk.
Collections / Objects / Methods / Properties
-
FileSystem object
- Microsoft ADO Data Control
- CT Summation’s CurrentCase object
-
CurrentCase.CoreDBPath
- CT Summation’s IMG object
-
IMG.CountPages
-
IMG.GetNthImgFile
Code
'This script verifies that the images in the Core database are actually physically
'present in the location that Summation is looking for them. If the images are not located
'on the path in the ImgInfo table, this script will create a file that contains the DocId number
'and the path to the image (including filename). The script will give the option to view the
'file/report at the end of the script. If the user chooses not to view the file right away, then
'a message box will appear telling them where the file can be found.
'The file is overwritten with each run of the script so there will not be a multitude of them
'to clean up periodically. The script can be modified to create multiple files so that each
'will not be overwritten by the last in much the same way that the Case Organizer backup
'script creates multiple backups.
'Creates an ADODB connection
Set cn = CreateObject("ADODB.Connection")
cn.ConnectionString = "Provider=SBP.1;Data Source=" & CurrentCase.CoreDBPath()
cn.Open
'Creates a recordset object to hold the recordset for the Imginfo table
Set rsImgInfo = CreateObject("ADODB.Recordset")
rsImgInfo.Open "Select * from imginfo", cn
'Creates a File system object to use for FileExists and to write to the text file
Set fso = CreateObject("Scripting.FileSystemObject")
'Sets some variables to cut down on typing and to make sure they
'don't have any existing values in them
Filename = "ImageVerify"
CheckField = "ImgFiles"
Failed = "ImgTag" & " " & "Image File" & vbCrLf
'Call the function to verify if the image files exist where Summation
'thinks they should
Call VerifyImages
'**************************************************************************************
'The main wrapper that checks to see if the image files referred to
'in the ImgInfo table actually exist in that location
Sub VerifyImages
'Sets ImgLoc to the Summation default image location to account
'for @I values in the DefDir field
imgLoc = img.ImgLoc
rsimginfo.movefirst
'Loops while the ImgInfo table has records in it
While Not rsimginfo.EOF
Dir = rsimginfo.Fields("DefDir").Value
Images = rsimginfo.Fields(CheckField).Value
'Replaces any @I values with the actual path
If InStr(Dir, "@I") Then
Dir = Replace(Dir, "@I", ImgLoc)
End If
'If the ImgFiles field contains a { or a Carriage return (chr(13)) then
'that means that there are probably multiple image files associated
'with that record
If InStr(Images, "{") > 0 Or InStr(Images, Chr(13)) Then
Call MultiVerify(Dir, Images)
'Otherwise it's a single image file and we can just check it
Else
ImgFile = Dir & Images
FileStatus = fso.FileExists(ImgFile)
'If the file doesn't exist then we add it to the failed string
If FileStatus = 0 Then
Failed = Failed + rsImgInfo.Fields("ImgTag") & " " & ImgFile & vbCrLf
End If
End If
rsimginfo.movenext
Wend
'Calls the function that writes out the failed string to a text file.
Call MakeLogFile
End Sub
Function MultiVerify(Dir, Images)
'Deals with the files that are not iterated, but just separated by carriage returns
'Replaces the carriage return (Chr(13) with a semi-colon which is what the
'Imaging object uses -this will allow us to use Summation functions like
'img.CountPages and img.GetNthImgFile. Then it replaces the line feed
'Chr(10), with nothing so that the line feed won't interfere with the file find.
If InStr(Images , Chr(13)) Then
images = Replace(Images , Chr(13), ";")
images = Replace(Images, Chr(10), "")
End If
'Cycles through the images associated with the current record
For i = 1 To img.CountPages(Images)
'Gets each individual page of the image and assigns it to ImgFile
ImgFile = img.GetNthImgFile(Dir, Images, i)
'Uses the File System Object to see if the file exists
FileTest = fso.FileExists(ImgFile)
'If the file can't be found where the imaging system will look for it
'then it gets written to a file.
If FileTest = 0 Then
Failed = Failed + rsImgInfo.Fields("ImgTag").Value & " " & ImgFile & vbCrLf
End If
Next
End Function
'The log file that is created will be saved to the case directory, but the previous one
'will always be overwritten by the most current one. This can be changed
'through the file system object, but in this case, it seemed best to
'allow it to be overwritten. This also prompt the user to see the file right away
'if they say no, it tells then where to find it later.
Function MakeLogFile
If Failed <> "" Then
Set f1 = fso.CreateTextFile(CurrentCase.CaseDir & Filename & ".txt", True)
f1.WriteLine(Failed)
f1.Close
SeeFile = AskYesNo("Would you like to see the list of images that couldn't be found?")
If SeeFile = -1 Then
addhtmlview "ImgLog", CurrentCase.CaseDir & "ImageVerify.txt"
Else
Msg "To look at this file in the future it will be in:" & vbCrLf _
& CurrentCase.CaseDir & "ImageVerify.txt"
End If
Else
Msg "All of your images were found."
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.