8 Replies Latest reply: May 15, 2014 10:16 AM by Grant Perkins RSS

    Monarch Utility Command Line

    KEVIN KENNEDY

      To loop through an entire folder using batch scripting to insert line breaks into files with line lengths greater than 4000 characters, what is the syntax of the command line (beginning with "FOR")? And must the stated "linelength" parameter be repeated 3 times as shown in the help file?

        • Monarch Utility Command Line
          Olly Bond

          Hello K Kennedy,

           

          The linelength parameter (I think) refers to the segments into which the long lines need to be chopped. So you could break a 5000 character line into two lines of 2500 characters each, or four lines of 1250, and so on.

           

          Are all your files the same format? Sorry not to have syntax to hand but this sort of thing doesn't crop up very often!

           

          Best wishes,

           

          Olly

            • Monarch Utility Command Line
              KEVIN KENNEDY

              Yes, all files are the same format, plain text that should have a length not exceeding 150 characters.

              • Monarch Utility Command Line
                KEVIN KENNEDY

                The reports in question generate the '4000 character' error message because at the end of almost every report is a mass of ASCII 152 characters (12,290 in a sample report I just checked). Can the string replacement remove these? If so, what do I use as a search string?

                  • Monarch Utility Command Line
                    Olly Bond

                    Hello K Kennedy,

                     

                    You might find that removing unprinted ASCII control characters via the Options > Input helps in Monarch?

                     

                    All the best,

                     

                    Olly

                      • Monarch Utility Command Line
                        Grant Perkins

                        Monarch Utility has a string replacement function that should be useful  for the ASCII character problem. A string can be a single character.  Try replacing ASCII 152 with a space to start with - or maybe some other  character that will be eliminated by Olly's suggestion above.

                         

                        A  messier approach, if the above does not work, would be to make each one a  CRLF although you may end up with a lot of blank lines at the end of  the report.

                         

                        Perhaps you could swap, say, 150 ÿ characters for a  single CRLF to reduce the number of lines. Obviously you could  potentially make all 12,290 a single CRLF but it would probably only  work for that report! Sometimes a multi-step reduction is worth  considering (e.g., reduce 10 to 1. Repeat until the remaining number is  very small) but this is usually more effective in programming rather  than scripting, though not impossible in a script or even in a powerful  editor.

                         

                        Mentioning editors, if these reports are rare inputs and  all the unrequired characters are at the end then using an editor to  simply strip the disruptive lines off the end of the report might make  sense. If the inputs have some variability report by report manual  stripping would allow people to spot any new abnormalities that may  suddenly appear and so take corrective action.

                         

                        Of course that is probably not a great idea if you are processing many reports a day!

                         

                        There  may be some other approaches too but really one has to have sight of  the reports and time to play with them to assess what other options may  be possible.

                         

                         

                        HTH.

                         

                         

                         

                        Grant

                          • Monarch Utility Command Line
                            Olly Bond

                            Hello K Kennedy,

                             

                            The input options didn't help - they can handle ASCII 0-31 characters only, so Utility is the right tool for the job.

                             

                            According to the manual,

                             

                            FOR %%f IN ("c:\test\*.prn") DO "C:\Program Files (x86)\Datawatch\Monarch\Program\MonarchU.exe" %%f %%f /cr "ÿ"[/CODE]

                             

                            should be the format for the replacement of all the "ÿ" characters, while:

                             

                            FOR %%f IN ("c:\test\*.prn") DO "C:\Program Files (x86)\Datawatch\Monarch\Program\MonarchU.exe" %%f %%f /lr 1000 1000 1000 1000 1000[/CODE]

                             

                            should work for the linelengths method.

                             

                            I don't have data with 12,000 horrible characters in, but you might get away with just one "1000" to specify that all lines should be split at that length, or you might need 13 of them.

                             

                            Hope this helps,

                             

                            Olly