IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#57832 - 12/31/20 03:18 PM Naming convention for split batches
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
I hope you all have a wonderful long weekend and a happy new year full of health and wealth!

I need a quick help on how to concatenate PDF files with the right naming convention.

My process creates PDF and mergers files according to their pages and number of records on each split. For example if I have a PDF with 8 pages long my current process concatenate them on number of page Variable and number of records individually!

I"m incrementing number of records via VB scrip but right now it's generating multiple PDF file with record count like


example
File_AAA_1 Record_8_pages.pdf
File_AAA_2 Record_8_pages.pdf
File_AAA_3 Record_8_pages.pdf

How can I Concatenate all the 3 files in one file to be named as below

File_AAA_3 Record_8_pages.pdf

Your help is appreciate.
Happy Warm 2021
_________________________
Peace

Top
#57833 - 12/31/20 03:46 PM Re: Naming convention for split batches [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
You could first let all the files accumulated into a folder until the PDF Creation and splitting is done.

Then using the File Listing plugin, get the list of all files that matches your criteria for merging, like in your case:

File_AAA_* Record_8_pages.pdf as the filemask. Then use this list to concatenate only the file in it and you can use the count value, from the resulting XML file, to name you final PDF as below:

File_AAAxmlget('/files[1]/@count',Value,KeepCase,NoTrim) Record_8_pages.pdf
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57834 - 01/04/21 11:38 AM Re: Naming convention for split batches [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
Hi Jean,

Thanks for the reply but I'm not sure if this method works for my situation, there are multiple files with different page numbering, for example once all the files accumulated into a folder we might get below ranges:

File_AAA_1 Record_8 pages.pdf
File_AAA_2 Record_8 pages.pdf
File_AAA_3 Record_8 pages.pdf
= ( File_AAA_3 Record_8 pages.pdf)

File_BBB_1 Record_25_pages.pdf
File_BBB_2 Record_25_pages.pdf
= ( File_BBB_2 Record_25 pages.pdf)

File_CCC_1 Record_18_pages.pdf
File_CCC_2 Record_18_pages.pdf
+....
File_CCC_40 Record_18_pages.pdf
= ( File_CCC_40 Record_18 pages.pdf)

File listing plugin will list all the file in the folder, now I need to concatenate files accordingly.

How do I do this?

Thanks


Edited by Sami786 (01/04/21 11:40 AM)
_________________________
Peace

Top
#57835 - 01/04/21 01:06 PM Re: Naming convention for split batches [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
I'm also thinking to concatenate files with number of pages on sub folders, like one folder for each page counts, and then go to each folder and use File Listing plug-in to find count number, and then I can concatenate all individual PDF files in one with the right count! but I don't know how to go and open each folder on the fly! is this feasible?


Edited by Sami786 (01/04/21 01:07 PM)
_________________________
Peace

Top
#57836 - 01/04/21 01:39 PM Re: Naming convention for split batches [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Working on a solution, will post soon!!!
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57837 - 01/04/21 03:33 PM Re: Naming convention for split batches [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Ok, here's what I got for you:

You will first need to define 4 new local variables:
  • prefix
  • suffix
  • inputFolder
  • count

  1. Beginning of your process where your PDF get created...
  2. Folder Listing plugin
    • sorted by name
    • File mask = *.*
  3. Using Set Jobs Infos and Variables, set %{inputFolder} to xmlget('/files[1]/folder[1]',Value,KeepCase,Trim)
  4. Change Emulation plugin, set XML
  5. XML Splitter
    • Condition = When condition node is found
    • New file root structure = Keep XML structure
    • Split on node = /files/folder/file
  6. Run Script plugin which set prefix to the first part of the filename (part that doesn't hold the numeral increment of your file Ex: File_AAA_1 Record_8 pages.pdf) and suffix which holds the last part of the filename (part that doesn't hold the numeral increment of your file Ex: File_AAA_1 Record_8 pages.pdf). I suggest you use RegEx.
  7. Branch
  8. Folder Listing plugin
    • Input folder= %{inputFolder}
    • sorted by name
    • File mask = %{prefix}*%{suffix}
  9. Using Set Jobs Infos and Variables, set %{count} to xmlget('/files[1]/@count',Value,KeepCase,Trim)
  10. XML Splitter
    • Condition = When condition node is found
    • New file root structure = Keep XML structure
    • Split on node = /files/folder/file
  11. Folder Capture as an Action
    • Folder = %{inputFolder}
    • Masks = %{prefix}%i%{suffix}
  12. Send to Folder
    • Folder = <your folder output for concatenation>
    • File name = %{prefix}%{count}%{suffix}
    • Concatenate files checked
    • Separator string = <empty>
  13. Delete plugin at the end of the main branch


Now, a little explanation on what happens up there wink

  1. The first part of your current process
  2. Get the list of all PDF files
  3. Set the input folder into a variable to keep it
  4. Forcing emulation to XML. Not always necessary, but do it anyway.
  5. Splitting the XML per file. (That becomes a loop...important!!!)
  6. Script that set some variable to values using Regex. Since the previous step is a loop, they will change for each file, as well as %i.
  7. We branch
  8. Get a new list of file that matches the first set of files (prefix, * <wildcard>, suffix).
  9. We get the count of file that matches the set and store it into a variable
  10. We split, again, per file. That is a new loop, inside the previous one.
  11. We capture the the current inner loop file.
  12. We concatenate it to any already existing file in the output folder. If not, it becomes a new file. End of that branch.
  13. <my end but it could be different for yours> back to the main branch.


All of this might need some adjustment on your part but that gives you a general idea.


Edited by Jean-Cédric (01/05/21 07:47 AM)
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57838 - 01/04/21 04:42 PM Re: Naming convention for split batches [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
very nice puzzle lol wink I'll do my best to put the puzzles together to get the final image working!

Thank you so much
_________________________
Peace

Top