Combine Text (.txt) files in UiPath


I have a folder containing 10,000 txt files and want to combine them into a pdf or text file.

Can this be done? Currently I assigned the file and then am running for each and read file.



Please check below thread and follow the steps.

Can anyone help me for text file consolidation? - #2 by lakshman

Yah it can be
Use a assign activity like this
arr_files = Directory.GetFiles(“yourfolderpath”,”*.txt”)

Where arr_files is a variable of type array of string
—now use a for each activity and pass the above variable as input and change the type argument as string in the property panel
—inside the loop use a READ TEXT FILE ACTIVITY And pass the input as item.ToString
And get the output with a variable of type string named str_input
—now use a assign activity like this
str_output = str_output + Environment.Newline + str_input
Where str_output is a variable of type string with default value as string.Empty defined in the variable panel

—followed by this For each loop use a WRITE TEXT FILE activity and mention the input as str_output and the file path of the text file

That’s all you are done
Cheers @sparkplug93


Error in the foreach step

Combine TXT.xaml (8.4 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.