Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
JayQueue
Creator
Creator

Aggregate files with the same prefix

Hello,

I'm reading a directory with tFileList:

05bc5d63-aef5-4e76-8d7b-789957117d31.pdf

0e9b95e7-5875-47dd-8c54-14293586ac8d.pdf

0e9b95e7-5875-47dd-8c54-14293586ac8d_Bijlage 210120065.pdf

1ab11ca4-fabf-4ace-ba6a-a32391dbb49d.pdf

1ab11ca4-fabf-4ace-ba6a-a32391dbb49d_Bijlage 210120017.pdf

...

And I want to merge the PDFs. Ie:

0e9b95e7-5875-47dd-8c54-14293586ac8d.pdf

0e9b95e7-5875-47dd-8c54-14293586ac8d_Bijlage 210120065.pdf

to

0e9b95e7-5875-47dd-8c54-14293586ac8d_merged.pdf

And

1ab11ca4-fabf-4ace-ba6a-a32391dbb49d.pdf

1ab11ca4-fabf-4ace-ba6a-a32391dbb49d_Bijlage 210120017.pdf

to

1ab11ca4-fabf-4ace-ba6a-a32391dbb49d_merged.pdf

etc.

What I tried:

  • tfileList (get all the UUIDs) -> tFileList (process by UUID)
  • with a tLoop

I can't seem to figure it out.

Can oneone point me in the right direction? 🙂

Sincerely,

Jonathan

Labels (2)
1 Solution

Accepted Solutions
JayQueue
Creator
Creator
Author

Fixed:

tFileList -- Iterate -- tJavaFlex

 

Start:

ArrayList<String> myFiles = new ArrayList<String>();  

String fileNamePath = ((String)globalMap.get("tFileList_5_CURRENT_FILEPATH"));

String fileName = ((String)globalMap.get("tFileList_5_CURRENT_FILE"));

String prefix = fileName.substring(0, 36);

System.out.println("Merging " + fileName);

 

Main:

myFiles.add(fileNamePath);

myFiles.add(context.invoiceFolder + prefix + ".pdf"); 

File file1 = new File(myFiles.get(0));

File file2 = new File(myFiles.get(1)); 

PDFMergerUtility pdfMerger = new PDFMergerUtility();

pdfMerger.setDestinationFileName(context.invoiceFolder + "/"+ "factuur_" + prefix + ".pdf");

pdfMerger.addSource(file2);

pdfMerger.addSource(file1);

pdfMerger.mergeDocuments(null);

 

End:

Just a simple System.out.println();

 

 

View solution in original post

3 Replies
Anonymous
Not applicable

Hi

Do you just want to merge the file name or merge the file content aslo?

 

Regards

Shong

JayQueue
Creator
Creator
Author

Hello,

 

I need to merge the file content with PDFMerge but I can't seem to group them

JayQueue
Creator
Creator
Author

Fixed:

tFileList -- Iterate -- tJavaFlex

 

Start:

ArrayList<String> myFiles = new ArrayList<String>();  

String fileNamePath = ((String)globalMap.get("tFileList_5_CURRENT_FILEPATH"));

String fileName = ((String)globalMap.get("tFileList_5_CURRENT_FILE"));

String prefix = fileName.substring(0, 36);

System.out.println("Merging " + fileName);

 

Main:

myFiles.add(fileNamePath);

myFiles.add(context.invoiceFolder + prefix + ".pdf"); 

File file1 = new File(myFiles.get(0));

File file2 = new File(myFiles.get(1)); 

PDFMergerUtility pdfMerger = new PDFMergerUtility();

pdfMerger.setDestinationFileName(context.invoiceFolder + "/"+ "factuur_" + prefix + ".pdf");

pdfMerger.addSource(file2);

pdfMerger.addSource(file1);

pdfMerger.mergeDocuments(null);

 

End:

Just a simple System.out.println();