How to count pages in a JOB_ or GRP_?

  1. XPP 9.2.2 on Windows Server 2012. We log in to WS 2012 using Remote Desktop.
  2. I have access to a cmd.exe window. I'm no expert at batch files though. I only know basic stuff.
  3. I have access to Powershell, which is already installed, but I have not used it before.
  4. I'm very familiar with Perl and text editors, so a Perl solution would be fine too.

Our JOBs are made up of many divisions, sometimes 20 divisions. In one case there are 45 divisions. We'd like an easy way to add up the pages for all divisions that begin with 2 numbers and a dash. The regex would be ^DIV_\d{2}\-. All other divisions are backups of divisions and are not part of the official book. So we do not want to count backup divisions in the page count.

Also, we are updating 24 JOBs for one customer. We'd like a way to add up the pages for all jobs in a GRP_ section, adding up only pages from divisions where the name starts with ^DIV_\d{2}\-.

Thank you!

  • First, it looks like each page in a DIV is stored in its own file that starts with "j." but how do I ignore different sessions for the same page to count the pages?
  • Another route would be to use the closing root tag to output %totpage to a text file (e.g. totpage.txt) that is then looked for and the contents read by your batch file (I'd use Perl rather than batch file syntax. IMHO). You can easily create a JOB tool that trawls all the DIV folders looking for the target file ('totpage.txt'), opens, reads, adds to the accumulated total, closes etc. That wouldn't be too difficult to write using standard Perl and minimal XyPerl to write the data out.

    You're job tool could also make use of a Doc Assembly ticket if there was one, or using regex (as you described) to only scan target DIVs.

    You could also check - as you've described - by counting XPP's page files but that seems like harder work.
  • Chuck,

    If you really want to make your life easier, have a look at the 'showpages' utility.
    (do a 'xyhelp showpages' to see all the options...)

    You might run the following command at the job level:
    "showpages -t -job -all"
    this will gives you a total by division AND a grand total of all pages in all divisions

    "showpages -t -job"
    will use the DA ticket to see what divisions are active, so it will only count those

    and you can also do this:
    "showpages -t -job -div div1,div2,..."
    to get the count of only certain divisions.
    (sorry but you can not use a regex in the division name, see below for that)

    So if you are fluent in perl, you should have no trouble running a listing of the job folder, filter out the divisions you want, remove the "DIV_" part of the division name, put all of that in a string (lets say: $divs" and finally run a system command that more or less looks like:
    "showpages -t -job -div $divs"
    and then grep the last line of the output.

    Once you have that routine worked out, it should not be big deal to repeat the job level count routine on all jobs that live under a particular group or even class.

    Good luck
  • Excellent answer from Bart, as usual.

    I've incorporated /showpages/ in a couple of tools here. One tool checks for "lost & found" pages only -- this is really useful for batch-composed PDFs (i.e. from a CCMS via XPPWS) that no one in our department ever reviews. When the tool detects L&F pages, we then run /showxsf/ to list the image names in those L&F pages, then the tool sends an email to the author who pushed the publish notifying them that there are possible issues with one or more pickups/images and their placement (or failure to place), and the images name(s).

    Edited for illustration purposes only--

    my $stderrfh = "/tmp/showpages.errs." . &Timestamp ;
    my $opts = '+p -fl -xsh -nol';
    my ($err,$core,@lfpages) = TLC::Xpp::Showpages($dpath, $stderrfh, $opts);
    my @lflines = grep /(Frst|Last) p/, @lfpages;
    scalar @lflines && do {
    my $stderrfh = "/tmp/showxsf.errs." . &Timestamp ;
    my $opts = '-laf -nol';
    my ($err,$core,@lfsxf) = TLC::Xpp::Showxsf($dpath, $stderrfh, $opts);
    @lfgrafs = grep /\/GRAPH/, @lfxsf;
    @lftech = grep /(dldid=|\d: )/, @lfxsf;
    };

    Note: the package TLC::Xpp is, I believe, a professional services-supplied package. Substitute whatever tried-and-true Perl XPP subroutines you may have on hand, or simply a well-formed system call with appropriate error checking.
  • Hi Chuck,

    Another XPP utility you might want to take a look at is the xsftree program. It's designed for running programs at specified levels within an XPP root/handle.

    Check out 'xyhelp xsftree' and the section on xsftree in the Command Line Utilities manual.

    There are a number of XyPerl scripts in the XYV_EXECS/bin folder (xsf*.pl) that use xsftree that you can look at as examples of how to use it.