#57832 - 12/31/20 03:18 PM
Naming convention for split batches
|
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]
|
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]
|
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]
|
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]
|
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]
|
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
- Beginning of your process where your PDF get created...
- Folder Listing plugin
- sorted by name
- File mask = *.*
- Using Set Jobs Infos and Variables, set %{inputFolder} to xmlget('/files[1]/folder[1]',Value,KeepCase,Trim)
- Change Emulation plugin, set XML
- XML Splitter
- Condition = When condition node is found
- New file root structure = Keep XML structure
- Split on node = /files/folder/file
- 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.
- Branch
- Folder Listing plugin
- Input folder= %{inputFolder}
- sorted by name
- File mask = %{prefix}*%{suffix}
- Using Set Jobs Infos and Variables, set %{count} to xmlget('/files[1]/@count',Value,KeepCase,Trim)
- XML Splitter
- Condition = When condition node is found
- New file root structure = Keep XML structure
- Split on node = /files/folder/file
- Folder Capture as an Action
- Folder = %{inputFolder}
- Masks = %{prefix}%i%{suffix}
- Send to Folder
- Folder = <your folder output for concatenation>
- File name = %{prefix}%{count}%{suffix}
- Concatenate files checked
- Separator string = <empty>
- Delete plugin at the end of the main branch
Now, a little explanation on what happens up there - The first part of your current process
- Get the list of all PDF files
- Set the input folder into a variable to keep it
- Forcing emulation to XML. Not always necessary, but do it anyway.
- Splitting the XML per file. (That becomes a loop...important!!!)
- 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.
- We branch
- Get a new list of file that matches the first set of files (prefix, * <wildcard>, suffix).
- We get the count of file that matches the set and store it into a variable
- We split, again, per file. That is a new loop, inside the previous one.
- We capture the the current inner loop file.
- We concatenate it to any already existing file in the output folder. If not, it becomes a new file. End of that branch.
- <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]
|
OL Expert
Registered: 01/29/14
Posts: 400
Loc: Home
|
very nice puzzle lol I'll do my best to put the puzzles together to get the final image working! Thank you so much
_________________________
Peace
|
Top
|
|
|
|
|
|