How To Remove 10 First Lines from Text Files located in Same folder?

Dears,

How To Remove 10 First Lines from Text Files located in Same folder ? Thx

1 Like

Hi,
whether all the files are in same format…?
If so then at least we have know the no. of characters present in the first line…
or we have know the last word of the first line in the first Text file…

if we have any of the above info then

read all files using directory.getfiles
using for each loop and string methods we can remove 10 first lines from the text…

No worries
Hope these steps could help you resolve this
—use a assign activity and mention like this
Out_filepath = Directory.GetFiles(“yourfolderpath”,”*.txt”)
—where Out_filepath is a variable of type string array
—now use a for each loop and pass the above variable a string input and change the type argument as string the property panel of for each loop activity
—inside the loop use a assign activity like this
Out_text = String.Join(Environment.NewLine, item.Split(Environment.NewLine.ToArray()).ToList().RemoveRange(0,10).ToArray)
—now we can pass this text as input to another text file using write text file and save it with a name followed by time stamp so that it will create a new file
Like this in the file path of write text file activity
“Yourfolderpath\yourfilename\”+”_”+Now.ToString(“dd_MM_yy”)+”.txt”

So this will create a new file of all existing file with first 10 lines removed

Simple isn’t it
Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @hsendel

1 Like

Thanks a lot Palaniyappan,
Well explained, I appreciate your usual support and help even though I have already found and existing example fits exactly my need :slight_smile:

1 Like

No worries
Cheers @hsendel

1 Like

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