Loop through folder with sub-folders and upload all files - How to

Hi All,

I have done the following coding that is
i want to open a folder which is on desktop. well the position of the folder can change ( i mean it can be on right side, or left side or top or bottom on the Desktop)

I have done the following coding that is

you can see in the properties window what all changes i have done… Well its opening the folder after opening every time i am getting the error for the selector -
image

Please help me

Thank you
Sonika

Well you may not to use the path or open application if you want to double-click and open the folder.

I have done like this:

  1. Used attached window
  2. Inside that used double-click activity, indicate the folder. (folder name can be a variable)

It will open the folder no-matter what is the position.

Try it and let me know.

2 Likes

@nadim.warsi
actually there is one folder by name - Unzip- inside this there are some folders
example: abca1, zxyx1,bbbzz1 etc {there can be 1 folder or there can be N number of folders in size “Unzip”}

these all above folders are having .pdf files only

Main thing is i have to open the folder Unzip and then open the other folders like - abca1
from the PDFSam software- double click/open the folder abca1 – {NOTE : the folder name can be anything how shall i make the BOT to click on the folders whose name are different every time ??? }

Another the main thing is when i click on Add button in the PDFSam then it should always
and always 1st select .pdf file that starts with{YKUL} out of many .pdf files in the folder abca1…

The same process should be followed for other all folders too… I think i have to loop through

Regards,
Sonika

@nadim.warsi

I tried as per your suggestion , but it dint work for me…

Please find the below screen shot
image

I’m checking your first post.
For this one can you put the click inside the do?

i have put it inside Do … it dint work

Did you indicate your Desktop on the Attach Window?

and i have not used any variable

If you just want to open application explorer.exe you can use start application and give this “explorer.exe” along with path you don not need to provide any selector at all

@Divyashreem

I have to do all the following things… I have tried to explain as much as i can…
Open the folder then select all the folders one by one…
ex: select Parent folder - AAAA
then select child folders inside it a1, b1 ,c1 one by one… The folder names can be anything…i have just given the example

@nadim.warsi

Please find the .xaml file … Emails.xaml (9.7 KB)

Got it, just use ```
var directories = Directory.GetDirectories(“your_unzip_directory_path”) this will return you all your sub directory in the form of array,
Then loop each directory and use Directory.GetFiles you will get list of files as array then you can filter file.extention =PDF and continue

You don’t not need to open manually and no need of selector as well

@Divyashreem

“Start Application” - no there is no activity by this name.
But start Process - is there in uipath.
I hvve added the start process - and gave the path - its opening the folder and then its throwing the error - “Start process : Application could not be opened”,

For your problem the solution I mentioned above should work. Get directory n get files

Ok @Seem, we have 2 things going on here.
For your initial requirement:

You can use the below xaml, edit as per your desktop version and folder name openDesktopFolder.xaml (6.6 KB)

For point 2 which is your req you will need to do the below just like @Divyashreem mentioned:

  1. In your workflow, assign the folder path =your_unzip_directory_path
  2. Use Directory.GetDirectories(“your_unzip_directory_path”) = list of directories
  3. For each folder in directories do Directory.GetFiles = list of files
  4. For each file in files do if file.StartsWith= “YKUL” [make sure that th file name is the only thing you have there not the path]
  5. Click Add and in that pass the whole file path.

So you dont need to tell the bot to do this bt rather create a workflow o get the file and then give it to bot to
upload.

2 Likes

@Divyashreem,

i have tried what ever you mentioned … So i am getting all the sub folders which r inside the Parent folder.
Once i get these SUB folders. I have to click on each SUB folder one by one

How shall i click on each folder one by one… In the click activity i am not able to find how to do it… But i have to click so i have used the - Click activity…

Please find the screen shot of the work i did.
image

In my application i have to click on - Add

image

Add opens the following window…

image

so now i have to click on each folder , which r present inside the Unzip , as in above screenshot.

after click the folder it opens the files present inside each folder. The folder consists of the following files
image

Now i have to click the file that is starting with - “MYKUL” – this should be selected 1st and then other all files should be selected.
NOTE: the files starting string is - MYKUL- and its subsequent string can be anything ex: MYKUL 123, or MYKUL xyz…

Thanks,
Soni

I dont think you need to click.
Inside that ForEach, your item = one folder under Unzip (say Invoice_3296504)
So you use Directory.GetFiles(item, “MYKUL*.pdf”)

Then that file along with the path you can pass to your pdfsam application add option pop-up where it asks for you to select the file you want to add type into the File name text box the whole path variable

Fr the above inside the for where you have done get folder then get file

  1. invoke a new workflow say pdfUpload
  2. in the in argument pass the file you got from above logic(it will automatically be full path …Desktop\CMK\Unzip\Invoice…)
  3. In pdfUpload, open the app, click on add and in file name type into the above in variable
1 Like

@nadim.warsi
Hi Nadim,

You mean to say i have to get file name- and pass the entire Path of the file to the screenshot u indicated.
but i have to select other all files too… :frowning:
Only thing is i have to make sure this MYKUL – file sits on Top.

Reards,
Sonika

Yes,

One way to do it is that,

  1. Get the file using filter = MYKUL*
  2. Get the list of files using filter not like MYKUL so you get the rest of the files
  3. Use invoke method to add file in point 1 to the top index 0 of the list

image

Then you can pass that list to the pdfUpload workflow to process one by one

1 Like