''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' EV script 013 - Export echogram images for all EV files in a folder ' Example Echoview COM script downloaded from www.echoview.com ' For support, contact the Echoview support team ' ' Instructions ' 1. Place the EV files that you wish to run the exports from into a single folder somewhere (good idea to create a backup first) ' 2. Define the variables that you want echogram images for on lines 41 and 42 of the code ' 3. When prompted, browse for your folder of EV files > OK ' 4. When prompted, browse for the folder you want to write your exported echogram-image files to > OK ' The script will cycle through each EV file in turn and run the echogram-image exports. ' Note that the echogram images are broken into 4 * 10,000-ping chunks. ' Note also the following caveat for EV files with more than one Fileset... ' The variable names defined on lines 41 and 42 of the script do not specify a Fileset name. Echoview therefore assumes that you ' mean the first Fileset in your EV file, whether that be the default name "Fileset1" or a custom name of your own choosing. ' If you wish to specify variables from a second or subsequent Fileset, then you need to specify this in the variable names, e.g. "Fileset2: Sv raw pings T1". ' This has the unfortunate consequence of then trying to include a colon (:) in the name of your export files, which causes the script to fail. ' The trick is to manipulate the export filename string within the script to seek out and remove the colon (:) and e.g. replace it with a dash (-) or a space. ' An example of this type of manipulation code is provided on line 107 of the script, which ignores non-EV files in the list of files to cycle through in your EV-file folder. ' Objects (obj) and strings (str) for later use ' - This script exports echogram images for 2 variables in each Echoview file ' - Enter the names of your variables between the quotation marks on lines 41 & 42 (some example names are provided as an illustration) ' - Add more variables as needed (if you do, remember to also add further commands after line 112) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim objEvApp Dim objFileList Dim objFile Dim objEvFile Dim objEvVariable1 Dim objEvVariable2 Dim strEvFileFolder Dim strExportFolder Dim strEvVariable1 Dim strEvVariable2 Dim strVariable1ExportFile Dim strVariable2ExportFile strEvVariable1 = "Sv raw pings T1" strEvVariable2 = "Sv raw pings T2" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' A function for choosing the EV-file and export-file folders ' - No need to change anything in this section ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject") Const conEvFileFolder = "" Const conExportFolder = "" Const conEvVariableName = "" Function GetFolderName(DialogTitle, DefaultPath) Dim objDlg: Set objDlg = CreateObject("Shell.Application") Dim objFileBrowser If objFSO.FolderExists(DefaultPath) Then Set objFileBrowser = objDlg.BrowseForFolder(0, DialogTitle, &H1, DefaultPath) Else Set objFileBrowser = objDlg.BrowseForFolder(0, DialogTitle, &H1, 17) End If Dim FolderName If InStr(1, TypeName(objFileBrowser), "Folder") > 0 Then On Error Resume Next FolderName = objFileBrowser.ParentFolder.ParseName(objFileBrowser.Title).Path If Err <> 0 Then Err.Clear Dim tmp: tmp = InStr(1, objFileBrowser.Title, ":") If tmp > 0 Then FolderName = Mid(objFileBrowser.Title, (tmp - 1), 2) End If End If On Error GoTo 0 Else QuitWithError "No folder selected." End If If Not objFSO.FolderExists(FolderName) Then QuitWithError "Invalid folder selected." End If GetFolderName = FolderName + "\" End Function strEvFileFolder = GetFolderName("Where are the EV files that you wish to use?", conEvFileFolder) strExportFolder = GetFolderName("Where would you like to save your exports?", conExportFolder) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' The EV files to cycle through ' - No need to change anything in this section ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Set objEvApp = CreateObject("EchoviewCom.EvApplication") Set objFileList = objFSO.GetFolder(strEvFileFolder).Files For Each objFile In objFileList subEvFileFinder objFile.Name Next objEvApp.Quit ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' The echogram-image exports to run for the chosen variables for each EV file in the folder ' - The echogram images are broken up into 4 * 10,000-ping chunks to optimise memory usage ' - Add extra ping chunks if your echograms have much more than 40,000 pings ' - Add extra objects, strings and commands if you added additional variables for export above ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub subEvFileFinder(FileName) If (UCase(Right(FileName, 3)) <> ".EV" Or UCase(Right(FileName, 12)) = " (BACKUP).EV") Then Exit Sub End If Set objEvApp = CreateObject("EchoviewCom.EvApplication") Set objEvFile = objEvApp.OpenFile(strEvFileFolder & FileName) Set objEvVariable1 = objEvFile.Variables.FindByName(strEvVariable1).AsVariableAcoustic() Set objEvVariable2 = objEvFile.Variables.FindByName(strEvVariable2).AsVariableAcoustic() strVariable1ExportFile = strExportFolder & FileName & " _" & strEvVariable1 strVariable2ExportFile = strExportFolder & FileName & " _" & strEvVariable2 objEvVariable1.ExportEchogramToImage strVariable1ExportFile & "_part1.png", 1080, -1, 10000 objEvVariable1.ExportEchogramToImage strVariable1ExportFile & "_part2.png", 1080, 10001, 20000 objEvVariable1.ExportEchogramToImage strVariable1ExportFile & "_part3.png", 1080, 20001, 30000 objEvVariable1.ExportEchogramToImage strVariable1ExportFile & "_part4.png", 1080, 30001, -1 objEvVariable2.ExportEchogramToImage strVariable2ExportFile & "_part1.png", 1080, -1, 10000 objEvVariable2.ExportEchogramToImage strVariable2ExportFile & "_part2.png", 1080, 10001, 20000 objEvVariable2.ExportEchogramToImage strVariable2ExportFile & "_part3.png", 1080, 20001, 30000 objEvVariable2.ExportEchogramToImage strVariable2ExportFile & "_part4.png", 1080, 30001, -1 objEvFile.Save() objEvApp.CloseFile(objEvFile) End Sub