web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : laZy0O5K4YE0AFgyUud1u7
Power Automate - Power Automate Desktop
Answered

how to combine pdf files from folder A and folder B and put them into folder C

Like (0) ShareShare
ReportReport
Posted on 21 Mar 2024 14:49:16 by 24

because of the workload and I found automation using PAD, here I want to combine the pdf files from folder A and folder B then put them into folder C. in the order of pdf files from folder A above and pdf files from folder B below
The following is an illustration of the contents of folder, folder B, and folder C

Folder A
1234_SEP.pdf
1235_SEP.pdf
etc

 

folder B
1234.pdf
1235.pdf
etc

 

C folder
with the new file name 1234.pdf (1234_SEP.pdf above and 1234.pdf below)

 

I hope that makes sense, Thanks in advance for your help

  • lagibingung Profile Picture
    24 on 21 Mar 2024 at 18:00:31
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    this works fine
    Thank you to all of you

    sorry if it makes you confused

  • lagibingung Profile Picture
    24 on 21 Mar 2024 at 18:00:03
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    this works fine
    Thank you to all of you

    sorry if it makes you confused

  • VishnuReddy1997 Profile Picture
    2,526 Super User 2025 Season 2 on 21 Mar 2024 at 17:43:54
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    Hi @lagibingung ,

     

    In Merge PDF Files action, please reverse the variables.

    FolderBfiles variable followed by FolderAFiles

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,204 Super User 2025 Season 2 on 21 Mar 2024 at 17:43:27
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    @lagibingung 

     

    Deenuji_0-1711043200411.png

     

    Got it!

    In the merge pdf action swap the variables. Now We have mentioned AFolderFiles[Counter].Fullname right. Now first place BFolderFiles[Counter].Fullname and move AFolderFiles to last.

     

  • lagibingung Profile Picture
    24 on 21 Mar 2024 at 17:35:36
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    I'm sorry, in folder A I forgot to change 1234SEP.pdf to 1234_SEP.pdf, maybe that's why there are no merged files in the output folder

    now the pdf has been combined and named accordingly

    The problem this time is, the pdf in folder A is located on page 2 while the pdf in folder B is located on the first page, can the mergedpdf feature on PAD make the pdf file in folder A located on the first page?

  • Deenuji_Loganathan_ Profile Picture
    6,204 Super User 2025 Season 2 on 21 Mar 2024 at 17:25:32
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    @lagibingung 
    Pls share screenshot of folder A and B if possible? I can assist you in more appropriate way by finetune my above code.

     
  • VishnuReddy1997 Profile Picture
    2,526 Super User 2025 Season 2 on 21 Mar 2024 at 17:14:58
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    Hi @lagibingung ,

     

    Both works bit similar. Just try my new updated solution.

    If it doesn't work, we will see.

    Let me know whether it worked or not.

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

  • VishnuReddy1997 Profile Picture
    2,526 Super User 2025 Season 2 on 21 Mar 2024 at 17:11:28
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    Hi @lagibingung ,

     

    Please find the solution for naming the file after merging.

    VishnuReddy1997_0-1711041033530.png

     

    Please copy the updated below code to your flow.

     

    Code:

     

    Folder.GetFiles Folder: $'''C:\\Users\\vr79540\\OneDrive - Cyient Ltd\\Desktop\\Power Automate Desktop\\Practice\\Combine PDFS\\Folder A''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> FolderA_Files
    Folder.GetFiles Folder: $'''C:\\Users\\vr79540\\OneDrive - Cyient Ltd\\Desktop\\Power Automate Desktop\\Practice\\Combine PDFS\\Folder B''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> FolderB_Files
    SET Counter TO 0
    LOOP FOREACH CurrentItem IN FolderA_Files
    Text.SplitText.SplitWithDelimiter Text: FolderA_Files[0].Name CustomDelimiter: $'''_''' IsRegEx: False Result=> TextList
    Pdf.MergeFiles PDFFiles: $'''{ \"%FolderA_Files[Counter].FullName%\", \"%FolderB_Files[Counter].FullName%\" }''' MergedPDFPath: $'''C:\\Users\\vr79540\\OneDrive - Cyient Ltd\\Desktop\\Power Automate Desktop\\Practice\\Combine PDFS\\Folder C\\%TextList[0]%.pdf''' IfFileExists: Pdf.IfFileExists.AddSequentialSuffix PasswordDelimiter: $''',''' MergedPDF=> MergedPDF
    Variables.IncreaseVariable Value: Counter IncrementValue: 1
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

  • lagibingung Profile Picture
    24 on 21 Mar 2024 at 17:10:34
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    can the script be made from the script @Deenuji  described?

  • lagibingung Profile Picture
    24 on 21 Mar 2024 at 17:08:51
    Re: how to combine pdf files from folder A and folder B and put them into folder C

    OK, thanks for the explanation, here I start to understand how your script works

    Here there is a problem with the output folder after merging files, there are no merged PDF files there

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete