Here is a script to do the dull job.
First upgrade the catalog and change the constant values in the macro. The macro scans the therectory for imr files. The macro runs against the newest version. In the destination directory a rename_reports.bat is generated to rename the new converted reports to the original reportnames.
If youy have questions feel free..!
Martijn
option explicit
' ** CONSTANTS **
'
const EXTENTION = "~V7_1.imr"
const REPORTDIRECTORYPATH = "C:\Temp\input"
const ADMIN_NAME = "Administrator"
const ADMIN_PASSWORD = ""
const OFS_MAXPATHNAME = 128
const FATAL_ERROR = 100
const USERS_LOG_FILE = "rename_reports.bat"
' ** STRUCTS **
'
Type OFSTRUCT
cBytes As String*1
fFixedDisk As String*1
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName As String*OFS_MAXPATHNAME
End Type
' ** GLOBAL VARIABLES **
'
Dim giLineNumber As Integer
Dim gsInUsersFile As String
Dim gscmdline As String
' ** FUNCTIONS **
'
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
'API function declarations
Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
'Log results to log file
Declare Sub LogMsg(strLog As String)
'Open log file and make headertext
Declare Sub StartLogFile
'Close log file
Declare Sub CloseLogFile
'Check if file exists
Declare Function FileExists(FileName As String) As Integer
' ** MAIN **
'
Sub Main()
Dim objImpApp As Object
Dim objImpRepp As Object
Dim ReportName As String
Dim NewReportName As String
Dim FileName As String
Dim NewFileName As String
Dim ReportDirectory As String
Dim count As Integer
Dim A()
Dim X
'Open log file
StartLogFile
'Set new catalog path and report directory
ReportDirectory = REPORTDIRECTORYPATH & "\*.imr"
'open application and make application visable
Set objImpApp = CreateObject("Impromptu.Application")
objImpApp.Visible 1
count=1
ReDim A(1000)
'Set directory to scan
FileName= Dir (ReportDirectory)
Do While FileName<>""
ReportName = mid(ReportDirectory,1,Len(ReportDirectory) -5) & FileName
Set objImpRepp = objImpApp.OpenReport (ReportName)
'Give Impromptu some time to open the report and retrieve the data.
Call Sleep(3000)
'Save the active report' the new catalog loaction will be saved.
NewReportName = mid(ReportName,1,Len(ReportName) -4) & EXTENTION
objImpRepp.Saveas NewReportName
NewFileName = mid(FileName,1,Len(FileName) -4) & EXTENTION
'write rename command to batchfile
gscmdline = "rename " & """" & NewFileName & """ " & """" & FileName & """"
LogMsg gscmdline
'Close the active report
objImpRepp.CloseReport
A(count)=FileName
count=count+1
FileName=Dir
Loop
'close logfile
CloseLogFile
'Close IMP
objImpApp.Quit
'Clear Memory
Set objImpRepp = Nothing
Set objImpApp = Nothing
End Sub
'write a string to the logfile
Sub LogMsg(strLog As String)
print #3, strLog
End Sub
'Check if CSV file exist
Function FileExists(FileName As String) As Integer
Dim RetCode As Integer
Dim OpenFileStructure As OFSTRUCT
Const OF_EXIST = &H4000
Const FILE_NOT_FOUND = 2
RetCode = OpenFile(FileName$, OpenFileStructure, OF_EXIST)
If OpenFileStructure.nErrCode = FILE_NOT_FOUND Then
FileExists = False
Else
FileExists = True
End If
End Function
'Open logfile and create logheader
Sub StartLogFile
Dim strLogFile As String
'Logfile = Users.log in the workdirectory
strLogFile = REPORTDIRECTORYPATH & "\" & USERS_LOG_FILE
'Delete old logfile with the same name
If FileExists(strLogFile) Then
Kill strLogFile
End If
'Open logfile for writing
Open strLogFile for Output As #3
LogMsg "@echo off"
LogMsg "echo\"
LogMsg "echo Renaming of files from Version 7.1"
LogMsg "echo\"
End Sub
'Close logfile
Sub CloseLogFile
LogMsg ""
End Sub