@lagibingung
Please find the below step by step guide to achieve your goal.
1. **Get Files from Folder A**:
- Configure your folder A. For an instance I am choosing my folder name as "C:\User\Folder A".
- Set the variable `AFolderFiles` to store the list of files.
2. **Get Files from Folder B**:
- Configure your folder B. For an instance I am choosing my folder name as "C:\Deenu\Folder B".
- Set the variable `BFolderFiles` to store the list of files.
3. **Count Files in Each Folder**:
- Count the number of files in folder A and store the count in the variable `FileCountAFolder`.
- Count the number of files in folder B and store the count in the variable `FileCountBFolder`.
4. **Check File Counts**:
- Compare the file counts of folder A and folder B.
- If the counts are equal, proceed; otherwise, the process stops here.
5. **Merge Files with Similar Names**:
- Initialize a counter variable `Counter` to 0.
- Start a loop iterating from 0 to `FileCountAFolder - 1`.
- Split the names of files in folder A and folder B by underscores and periods respectively to extract the base file names.
- Compare the base file names from folder A and folder B.
- If the base file names match, merge the corresponding PDF files from both folders into a single PDF file.
- Save the merged PDF file in "C:\Deenu\Folder C" with the base file name.
- If a merged PDF file with the same name already exists, add a sequential suffix.
- Increment the counter variable by 1 after each iteration.
- Continue the loop until all files in folder A are processed.
Flow Screenshot:


Code:
Folder.GetFiles Folder: $'''C:\\Deenu\\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=> AFolderFiles
Folder.GetFiles Folder: $'''C:\\Deenu\\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=> BFolderFiles
SET FileCountAFolder TO AFolderFiles.Count
SET FileCountBFolder TO BFolderFiles.Count
IF FileCountAFolder = FileCountBFolder THEN
SET Counter TO 0
LOOP LoopIndex FROM Counter TO FileCountAFolder - 1 STEP 1
Text.SplitText.SplitWithDelimiter Text: AFolderFiles[Counter].Name CustomDelimiter: $'''_''' IsRegEx: False Result=> FileNameAList
Text.SplitText.SplitWithDelimiter Text: BFolderFiles[Counter].Name CustomDelimiter: $'''.''' IsRegEx: False Result=> FileNameBList
IF FileNameAList[0] = FileNameBList[0] THEN
Pdf.MergeFiles PDFFiles: $'''{ \"%AFolderFiles[Counter].FullName%\", \"%BFolderFiles[Counter].FullName%\" }''' MergedPDFPath: $'''C:\\Deenu\\Folder C\\%FileNameAList[0]%.pdf''' IfFileExists: Pdf.IfFileExists.AddSequentialSuffix PasswordDelimiter: $''',''' MergedPDF=> MergedPDF
END
Variables.IncreaseVariable Value: Counter IncrementValue: 1
END
END
How to copy and paste the above code into your desktop flows?

Thanks,
Deenuji Loganathan 👩💻
Automation Evangelist 🤖
Follow me on LinkedIn 👥
-------------------------------------------------------------------------------------------------------------
If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏