How to read all the files from the sub folder

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

hi @ray_sha

Ok means you are saying that once all the files read from all subfolders and just assume that some new files get added to all same subfolders. Then it must not read the files which are read previously and only read the new files.

RIght ??

Happy Automation :raised_hands:

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

hey @Pratik_Wavhal

say there are a total of 50 sub folders in the main file and in that first run 10 of which are processed.
The bot may be stopped of some reason.
Now in the second run, those 10 sub folders which were processed shouldn’t be processed again, the bot must continue from the 11th subfolder

Hey @ray_sha

I got your query.
One solution for that will be processed files should move to some other folders and this will be efficient also.
Or else you can record the names of processed files to excel but it will take more time to check whether that file name is present in the excel or not and then proceed further.

So you can choose the solution of moving the files.

Happy Automation :raised_hands:

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

Hey,

I am saved the processed sub folder in another folder.
Now I have to compare if the sub folders are present in the other folder as well.

How would I condition the if ?
Thanks

Folder names are text and not numbers… If you want the sequence then folders will have to be named like this:
Folder_00001,Folder_00002,Folder_00003...
Also you may need to Sort the items after your command varMyFiles=Directory.GetFiles("c:\myfolder","*.*", SearchOption.AllDirectories)
varMyFilesSorted = System.Array.Sort(Of String)(varMyFiles)

1 Like

hey @bcorrea,

Folder_00001,… Folder_000015 or Folder_00015??

Thanks in advance!

just make sure that if you have like 10 folders, that the ones from 1 to 9 have one zero to the left, and if you have more than 100 folders, that the 1 to 9 have 2 zeroes and the ones from 10 to 99 have one zero to the left…

1 Like

Hi @bcorrea

@ray_sha wants to say that assume that there are a total of 50 sub folders in the main file and the workflow i have given her is perfectly 100% working but now she wants that if my workflow is running and while running suppose something happens and bot gets stop in middle only while reading the files from subfolders.

So next time when she will run the bot that should skip the already processed/readed files and continue with the files that are remained to process/read.

So for that i gave her solution that she should move the files to another destination once they get processed.

So for that now her que is as below

I am saved the processed sub folder in another folder.
Now I have to compare if the sub folders are present in the other folder as well.
How would I condition the if ?
Thanks

Happy Automation :raised_hands:

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

1 Like

I would not give myself that trouble… I would just do everything again and overwrite if already there…

1 Like

Hi @ray_sha

I am saved the processed sub folder in another folder.
Now I have to compare if the sub folders are present in the other folder as well.
How would I condition the if ?

I have updated the workflow as per requested. Below is the updated workflow.
Updated_Ray_Sha.zip (8.3 KB)

Output :-
image

Within that subfolder names will be same as it is. Refer below SS :-

Main Folder :-
image
Copy of Main Folder :-
image

Within that subfolder inside all the files will also move same as Main Folder :-

Moved all files to Copy of Subfolder1 i.e., Empty Subfolder1 from Mainfolder


After reading all files comes to Copy of Mainfolder’s Subfolders
image

Mark as solution and like it :slight_smile:

Happy Automation :raised_hands:

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

1 Like

Thanks @Pratik_Wavhal @bcorrea

1 Like

hi @ray_sha

So the solution i have provided is useful for you now ??

Means does your issue is solved with my solution ??

If Yes then
Mark as solution :slight_smile:

Happy Automation :raised_hands:

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

1 Like

Hi Pratil_Wavhal,
Thanks for the solution,
But i have different file extenstions,i need to extract all of them,how can we do it.

thanks

Hi @Navya

I have already posted the solution on below thread. Have a look to it.

Mark as solution and like it der :slight_smile:

Happy Automation :raised_hands:

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

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