Which activity to use in for loop to read multiple PDF files? I did it for one file
In Read PDF Text activity instead of hard code file name just mention CurrentFile.Fullname. This will make it dynamic.
Thanks,
Ashok
Hi @UJJVAL_BHAGAT Pass the folder path in “In Folder” Section and in for each activity use rea pdf text as you used but pass currentfile variable as filename in the read pdf text activity without hardcoding it. And also make the write text file name dynamic , so you can get all the pdf files data in different text file.
Thanks
Armila Swain
The image you sent shows a UiPath workflow utilizing a for each loop to process multiple PDF files. Here’s a breakdown of the relevant parts:
- For Each File in Folder: This activity iterates through all files within a specified folder.
- Current File: This variable stores the path to the current file being processed in each iteration of the loop.
- Read PDF Text: This activity reads the text content from the PDF file specified in the File Name property.
In the example, the file name is set to "All files\invoice-Oct01(2).pdf"
. However, this points to a specific file and won’t iterate through multiple PDFs. To achieve that, you need to use an asterisk (*) as a wildcard character within the Filter by property of the “For Each File in Folder” activity. This will make the loop process all files with the .pdf
extension within the specified folder.
Check the below thread.
You need to pass CurrentFile.ToString
in Read PDF Text activity.
Regards
you have passed static as “All files\invoice-Oct01(2).pdf” insteed of the pass CurrentFile variable because CurrentFile holds the path of current file
Regards
you can use the For Each activity in combination with the Read PDF Text activity to iterate through and read multiple PDF files within a loop
// Get all PDF file paths in a folder (replace “C:\path\to\folder” with your actual path)
string filePaths = Directory.GetFiles(“C:\path\to\folder”, “*.pdf”);
// Loop through each file
foreach (string filePath in filePaths)
{
// Read text from the current PDF
string pdfText = Read Pdf Text(filePath).ToString();
// Process the extracted text (e.g., write to a file, display in message box)
// ...
}
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.