4 Replies Latest reply: May 15, 2014 10:08 AM by Data Kruncher RSS

    command line scripting

    jbrody _

      Monarch Pro v10.5

      I'm a long time user of Monarch since 6.0 but a neophyte when it comes to command line scripting. If you could please help me with some basic bat file I'd trully appreciate.  I'd love to use DataPump but alas our level of processing requests just doesn't sustain a server type of enviroment.



      We have a dedicated ip address server where our saved .* reports are contained in a dedicated directory.


      We need to have a script that can;


      1. grab the dozen or so . files using a wildcard mask and put them onto a local directory

      2. convert them into individual pdf reports into a specific holding directory (the font size needs to be changed to airal 8 and the page layout needs to be landscape) We use Adobe Acrobat Professional, and I'm guessing a printer default would need to be set up.



      1. grab the weekly . files using a wildcard mask and put them onto a local directory

      2. apply a Monarch model residing on local pc using a specific filter

      3. export to specific excel file stored in a specific directory.


      C. same as B but to an Access 2007 database.

        • command line scripting
          Olly Bond

          Hello jbrody,


          A couple of easy steps:


          net use x:




          copy x:\*.* c:\myfolder\*.*/CODE


          will get the files to where you want them.


          The other steps (2 & 3) for all three options (A, B, C) could be done in Monarch using a report export to PDF (with the right page setup options), and a table/summary export to Excel and Access. So it's just a matter of building the right model and and getting the script right.


          What is the input file format, and do you need to make use of the filename in the model? If it's text (or csv), and you don't need the filename, then:


          copy c:\myfolder\*.* c:\myfolder\report.prn[/CODE]


          would give you a single input file, with a static filename, allowing you to use a Monarch project and making the scripting trivial.


          Best wishes,



          • command line scripting
            Data Kruncher

            Hi jbrody and welcome to the forum!


            Sounds like an interesting and challenging project that you have.


            In the A section, you'll want to build a FOR loop of sorts in the batch file to process every file in the given folder. My memory of the exact syntax for such things isn't as sharp as Nick Osdale-Popa's is, so I'd need to research a bit for that.


            In my experience, scripting with Acrobat/Distiller is a serious pain. Though it can be done, avoid it all costs. On the positive note, you should be able to handle the PDF creation aspect of your project with a Monarch Project file. We can get into the specifics of that shortly.


            In the B, you'd use the same FOR syntax (whatever that is :rolleyes:) and then use a special model with the filter that you need activated when you saved and closed the model. The reason for this is that you cannot specify a particular filter to be used via command line parameters. You can do that via the COM interface, as you would with VBA programming for instance, but not on the command line.


            You'd want to use project files for your sections B and C to handle the exports.


            I know that this is just a skeleton of the desired process, but does it help you to get started?

              • command line scripting
                jbrody _

                Sorry guys I really a neophyte when it comes to command line. 


                I did get the project to create a pdf file.

                  • command line scripting
                    Data Kruncher

                    While I haven't tested it myself, I'd think that this would work just fine (which borrows heavily from [URL="http://www.monarchforums.com/showthread.php?t=3288"]this post[/URL]):

                    @echo off


                    net use x:


                    copy x:\*.* c:\myfolder\*.*



                    (set reports=)


                    for %%i in ("C:\myfolder\*.*") do (set reports=!reports! /rpt:%%i)


                    "C:\Program Files\Monarch\Program\Monarch.exe" /prj:create_pdf_from_txt.xprj %reports% /pxall


                    (set reports=)


                    for %%i in ("C:\myfolder\*.*") do (set reports=!reports! /rpt:%%i)


                    "C:\Program Files\Monarch\Program\Monarch.exe" /prj:create_xls_from_txt_with_predefined_filter.xprj %reports% /pxall


                    (set reports=)


                    for %%i in ("C:\myfolder\*.*") do (set reports=!reports! /rpt:%%i)


                    "C:\Program Files\Monarch\Program\Monarch.exe" /prj:create_accdb_from_txt_with_predefined_filter.xprj %reports% /pxall


                    ENDLOCAL[/code][URL="http://ss64.com/nt/setlocal.html"]Further reference.[/URL]