Array's for Joining PDF Activities

Hey Everyone,

I’m trying to combine PDF’s in a specific order in a folder and there are 100’s of folders. In the folders, there’s 4 files that will always be named the same and there potentially could be more that are dynamic. Each Folder is named with the ‘Account Number’ and the pdf’s start with that ‘Account Number’.
Folder: 987612 (Acount Number)
987612.Salesforce.pdf
987612.Quotecheck.pdf
987612.Email.pdf
987612.Agreement.png.pdf
then any other pdf’s would be 987612.“File Name”.pdf

I need to combine these in this order: Email, Quotecheck, Salesforce, Agreement, * any other pdf’s in the folder.
I’m trying to use Join PDF files function as I don’t have access to document understanding in my license. Thanks for any help given.

David

@dgrooves

You can use the below

  1. For each folder in folder
  2. Inside that use join pdf with {Path.Combine(currentfolder.FullName,currentfolder.Name+".quotecheck.pdf"), Path.Combine(currentfolder.FullName,currentfolder.Name+".salesforce.pdf"), Path.Combine(currentfolder.FullName,currentfolder.Name+".agreement.pdf")}.ToList.concat(Directory.GetFiles(currentfolder.FullName).Where(function(x) Not x.Contains("salesforce") and Not x.contains("quotecheck") and not x.contains("agreement"))).ToArray

Cheers

Hi

I recently had to do something similar.

I would tackle your problem like this.

Step 1: Build an array (see Array1) of your known files,

Array1 = {“YOURxFOLDERxPATH\987612.Email.pdf”, “YOURxFOLDERxPATH\987612.Quotecheck.pdf”, “YOURxFOLDERxPATH\987612.Salesforce.pdf”, “YOURxFOLDERxPATH\987612.Agreement.png.pdf”}

Step 2: Capture all your unknown files into (see Array 2)

Array2 = Directory.GetFiles(“YOURxFOLDERxPATH”,"*. ").Except(Directory.GetFiles(“YOURxFOLDERxPATH”, “987612.Email.pdf”).Except(Directory.GetFiles(“YOURxFOLDERxPATH”, “987612.Quotecheck.pdf”).Except(Directory.GetFiles(“YOURxFOLDERxPATH”, “987612.Salesforce.pdf”).Except(Directory.GetFiles(“YOURxFOLDERxPATH”, “987612.Agreement.png.pdf”))).ToArray

Step 3: Merge the Array into a single Array of String

ArrayMerged = Array1.Concat(Array2).ToArray()

Step 4: Use MergePDF with ArrayMerged to generate the PDF in your required order.

Hopefully this helps.

Cheers

Steve

Hi @dgrooves , hope this is partially you are after

Please set the strExtn variable to ".pdf" in your case.