5 Replies Latest reply: May 15, 2014 9:52 AM by Data Kruncher RSS

    UPDATE .BAT TO V9?

    Sue@Tiffen _

      I am in the process of converting all of our old files from Monarch 5 to 9...

      Is there any easy way to convert all of the .bat files? There are several dozen! 

        • UPDATE .BAT TO V9?
          Data Kruncher

          Hi Sue,

           

          Off the top, I don't know of an easy way to do this. I thought about the search and replace with a text editor, or maybe a search and replace command in a batch file like you can with Unix's sed command (if you can, I don't know how, apart from third-party programs, so someone please inform me).

           

          So, not wanting to give up, I wrote a little Excel VBA program which should do the trick for you.

           

          You should be able to copy and paste it into a code module in a new xls file. Here we go:

          [font="courier"]Sub UpdateBatchFile()

              Dim sInputFile As String

              Dim sOutputFile As String

              Dim sText As String

              Dim MyFile As String

              Dim sBatchPath As String

               

              Dim iInputFileNumber As Integer

              Dim iOutputFileNumber As Integer

              Dim iLine As Integer

               

              '***********************************************

              '*** Change the folder location as necessary ***

              '***********************************************

              sBatchPath = "C:MyTest"

              sBatchPath = InputBox("In which folder do you want to update batch files?", "Your input is required.", sBatchPath)

              If sBatchPath = "" Then Exit Sub

                   

              If Right(sBatchPath, 1) <> "" Then

                  sBatchPath = sBatchPath & ""

              End If

               

              MyFile = Dir(sBatchPath & "*.bat", vbDirectory)

              Do While MyFile <> ""

               

                  sInputFile = MyFile

                  sOutputFile = sBatchPath & Left(MyFile, Len(MyFile) - 4) & " v9.bat"

                   

                  iInputFileNumber = FreeFile

                   

                  Open sBatchPath & sInputFile For Input As iInputFileNumber

                  iOutputFileNumber = FreeFile

                  iLine = 0

                  Open sOutputFile For Output As iOutputFileNumber

                   

                  Do While Not EOF(iInputFileNumber)

                      iLine = iLine + 1

                      Input #iInputFileNumber, sText

                      If InStr(1, sText, "monarch") > 0 Then

                          sText = InputBox("Please revise the command as necessary.", "Editing batch file: " & MyFile, sText)

                      End If

                      Print #iOutputFileNumber, sText

                  Loop

                  Close iInputFileNumber

                  Close iOutputFileNumber

                   

                  MyFile = Dir

              Loop

          End Sub  /font[/quote]I've tested it and it seems work nicely. It will scan a folder you specify for batch files and look through it for Monarch calls. When it finds one you'll be prompted to make any changes, and it'll leave the old batch file intact, and give you a new one with the old file name and a v9.bat extension, so "My File.bat" becomes "My File v9.bat".

           

          Hope this helps you go through this process more easily,

          Kruncher

          • UPDATE .BAT TO V9?
            Sue@Tiffen _

            I was able to make the changes as you have suggested...but now I am getting

            'monarch' is not recognized as an internal or external command,operable program or batch file....

            • UPDATE .BAT TO V9?
              Data Kruncher

              Make sure that you know exactly[/b] where the Monarch program is located on your computer.

               

              For instance it may be found at

              [font="courier"]  "C:Program FilesMonarch Pro V9ProgramMonarch.exe" /font[/quote]or

               

              [font="courier"]  "C:Program FilesMonarchProgramMonarch.exe" /font[/quote]I would expect the text appearing in the "Please revise" dialog to look something like this:

               

              [font="courier"]"C:Program FilesMonarchProgramMonarch.exe" /rpt:"C:Report FolderReport.txt" /mod:"C:Model FolderModel.xmod" /exp:"C:Export FolderMy Export.xls"[/font][/quote]

              • UPDATE .BAT TO V9?
                Sue@Tiffen _

                Worked like a Charm!

                 

                Thanks!

                • UPDATE .BAT TO V9?
                  Data Kruncher

                  Great!    

                   

                  Thanks for the update Sue.