I have a folder XYZ which has 3 files with extension .jpg, .txt , .pdf and their names are not constant. How can I read this file with activity read text file with just the extension name and not complete file name.
so long as there was only one txt file in the folder
you can do a for each file in folder activity with .txt filter enabled
Hi @anjasing
→ Use For each file in folder activity and there is a option called Filter by in that field give the extension which files you want to get. (*.txt). Output - CurrentFile
→ Inside for each insert the Read text file activity and give the CurrentFile to the File name field of the Read text file activity.
Check the below image for better understanding,
Hope it helps!!
hey @anjasing
To get the list of files matching to your extension you can:
- Create a variable
txtFiles
(String) =Directory.GetFiles("YourDirectory", "*.txt")
Now, you can use for each activity to read each file.
Hi Can I pass here different extensions like .jpg/.jpeg/.png in filter by??
@mkankatala
You cannot pass multiple extensions in filter you are able to pass only one… @anjasing
Hope you understand!!
Thank you so much. Got it. It worked.
You can write an expression that uses multiple filters.
For @mkankatala too
Hi @postwick
We can filter out multiple extensions with expression as mentioned in your post.
But Is it possible to pass multiple extension in the filter option in For each file in folder activity…?
No, so just write an expression that gets a list of all the files you want and use that expression in a regular For Each. The result is identical to For Each File in Folder.
Yes @postwick but in the beginning of the Post, they want to filter only .txt extension files, that’s why I suggested to use For each file in folder activity which is easy to use.
If they asked about multiple extension filtration then I’ll surely suggest them to use the expression for it.
And Thank you for the thread which is very useful for the Directory filtration expressions.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.