I have a folder with some .txt files and .png files.
I want to go through every .txt files inside that folder and find specific text.
If specific text is found, it will return the line of that specific text and the file name.
For looping through all the txt files you can try like this
Use For each file in Folder
Fill the fields with the appropriate fields and if your files are inside a folder like “YourPath\another folder” you need give the path upto your path and check the Include subfolders
In Filter By give your extension in your case you need to give “*.txt”
Assign Filename = CurrentFile.Name (it will give you Filemname.extension EG:" Sample.txt")
- If you want only the file name without extension use this File_Name=Path.GetFileNameWithoutExtension(CurrentFile.ToString)
And to get get specific value try this
Read Text File store in a variable
Generate Datatable activity and set the row seperators and column seperators in the options and save them in the variable (it will store as datatable)
From that data table you can filter the data using FilterDatatable activity or LINQ expression
Hi, this is the txt file. I want to search “type=A”
This is just a short one with only 2 lines. Other txt files might have thousand of lines but its structure is same as this.
in case of all file names should be filtered where type=a is present in the content we can do within a single assign (without for each, read text activities …)
(From f In Directory.GetFiles("C:\Users\carissa.lee\OneDrive - Kuok (Singapore) Limited\Desktop\EY auditors\SAP ID Reports\","*.txt")
Let ftxt = File.ReadAllText(f)
Where ftxt.toLower.Contains("type=a")
Select x=f).toArray
And for sure we can adopt if needed for checking lines, using regex as well