Can anyone help me for text file consolidation?

Hi folks,

I am new to this tool. Actually my requirement here, In my directory list of text files are available, so I want to consolidate all files together. I don’t know which activity I need to use inside the loop “For Each”. I have used read text file activity, but its through an error “Read Text File: One or more errors occurred”.


Welcome to the uipath community.

Try below steps to do this.

 textFiles [] = Directory.GetFiles("Folder Path","*.txt")

Above expression will read all text files from that folder and will give output as array of string. Then use For Each loop to iterate one by one file…

    ForEach item in strFiles
        - use Read Text file and pass item to it. 
       - use Append Text activity to append all files data.
1 Like

Welcome to uipath community
Hope these steps would help you resolve this
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 @Jagadeesanp

Thanks for your suggestion, I will check and let you know the status.


Check this workflow as well,

ConsolidateTextFiles.xaml (6.3 KB)

Thank you so much, perfectly its working. @lakshman

1 Like

Thank you so much, perfectly its working. @Palaniyappan

1 Like

Thanks for your response !!

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