How to read all the files from the sub folder

Hey all,

There is a main folder called - Main_Folder
inside Main_Folder are multiple sub folders called -Sub_folder_1 , Sub_folder_2, Sub_folder_3…Sub_folder_50
There are multiple files in those Sub_folders as well.

How can I read all the files from the Main_Folder (i.e read all the multiple files in the multiple subfolders)

Any idea?

Thanks in Advance!

Sequence13.xaml (11.1 KB) Main_folder.zip (1.3 KB)
I hope this may help you

Hey @Eric_Wong_Test

image

which activity is this?
I tried to restore the activity as well.

Thanks in Advance!

P3 P2 P1
I’m sorry I don’t know you don’t have which packages

Hey @Eric_Wong_Test,

Whats the name of the activity that you’ve used?




Hey @Eric_Wong_Test,

I’ll try and repair the dependency.
But isn’t there any method that can be used along with
System.IO.Directory.GetFiles(specified path with some value here)
which reads all the contents in the specified path?

any idea?

Using for each in directory.GetFiles(sub folder path)

for this we have to give all the path to the sub folders,
isn’t there any method where we can give the path till the main folder and use some manipulations for it to read the files in all the sub folders?

ArrayFolder=directory.GetDirectories( Main_Folder path)

2 Likes

thanks @Eric_Wong_Test

Hey @Eric_Wong_Test

I am able to retrieve all the files from the sub folder.

But after the first run it starts from the first, i.e. it starts to again process sub_folder_1

is there any way that if the file is processed in the first run mustn’t be processed again.

Thanks in advance!

I’m sorry I don’t know. In my knowledge, I think there are no methods can do it. You can find master help.

1 Like

Hi @ray_sha

I have created one workflow which gives perfect output that you want
Ray_Sha.zip (8.1 KB)

Mark as solution and like it :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

2 Likes

Hey @Pratik_Wavhal,
Thanks for the help!
but the sub folders wont be processed in a particular order.

hey @Eric_Wong_Test

Thanks for the Help!

Hi @ray_sha

but the sub folders wont be processed in a particular order.

Sorry, I didn’t get you. Means how the subfolder structure will be ??

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hey

The sub folders are numbered as Sub_folder_1, Sub_folder_2,…Sub_folder_n
But in the for each loop the bot doesn’t picks it up accordingly in the numbered sequence.

It picks up Sub_folder_1 first, then it can pick Sub_folder_12, and so on.

Hi @ray_sha

So you want that it should pick up the subfolder in sequence or not ??

When i run the same workflow here it is picking up in sequence only. Thats why i put the message box to see which folder is currently going on.

And if you are saying that After Picking Sub_folder_1 it picks Sub_folder_12 directly just bcz initially der is “1” so you have to rename those 1 to 9 folders as 01,02,… So on.

I haven’t tested it with more than 6 subfolders so i didn’t recognise that. If such thing is happen that after Subfolder1 it directly picks Subfolder12 then you must rename 1 to 9 folders as subfolder01, subfolder02, and so on till Subfolder09

May i know what actually you want as output and what you are facing now ??

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

Hey @Pratik_Wavhal,

So if I do so and its starts picking up in sequence

It wont read the same file twice?

Thanks