I need your help

i have a task, and i have to create a robot, which copies the folder names from excel table and searches in desktop, and has to count all pdf files(With different names) in the folder, and write again in excel table, but when the column “OK” is full, the robot has to skip row and count the next row.

Hello @momo10 ,
I did not understand what you meant “When column OK is full”. The value in column ok will be “Full”?
Rest can be done like this:

  1. Read the excel file using read range.
  2. Using for each row, get the folder name and assign the count in a variable using this:
    System.IO.Directory.GetFiles(FolderName,“*.pdf”).Count
  3. Write the count in B column.
  4. Write back the datatable to the excel using write range.

Hope this helps.
Thanks!
Athira

i mean if, column ok “X” has

Ok, so the workflow is like this:

  1. Read the excel file using read range.
  2. Use for each row and get the value in OK column. Using an if condition, check if it’s X. If it is, don’t do anything. Else perform the below steps:
  3. In else condition, get the folder name and assign the count in a variable using this:
    System.IO.Directory.GetFiles(FolderName,“*.pdf”).Count
  4. Write the count in B column.
  5. Write back the datatable to the excel using write range.

Thanks!
Athira

Hi @momo10 ,

Could you give this workflow a try?
You have to change the str_parentFolderPath, since we have to specify which directory these folders belong to before we can start counting the PDFs.

Also, replace the Build DataTable Activity with the Excel Read Range Activity.

str_parentFolderPath = "Parent folder path goes here"
(From row In dt.AsEnumerable()
Let res = If(row("OK").ToString.Trim.Equals("X"),
	row("Resultat").ToString, 
	Directory.GetFiles(str_parentFolderPath+"\"+row("Foldername").ToString,"*.pdf").Count().ToString)
Let ra = New Object(){row("foldername"),res,"X"}
Select dt_result.Rows.Add(ra)).CopyToDataTable()

GetPDFCount.xaml (7.8 KB)

Kind Regards,
Ashwin A.K

Hi @ashwin.ashok
I tried this step by step, but it did not work.

Hello @momo10 ,

Could you please check this workflow? I used the steps I explained earlier.

Sequence.xaml (12.5 KB)

Thanks,
Athira

hi @athira.somasekharan,
the programme does not work

Will paste the screenshots:
image

Hope it’s clear.
Thanks,
Athira

Hi @athira.somasekharan
I get the error message

I don’t understand the error message. It says the folder doesn’t exist?

yes, he folder doesn’t exist

Hi @momo10 ,

Not a problem, but we’d appreciate it if you could be a bit more descriptive of the error. There isn’t much I can do for you if all you say is “I tried something, and it didn’t work”.

Another question, do the folders that you have mentioned in the excel file exist, or do you want the bot to check if the folder exists and only then update it into excel?

The more details you offer, the closer we can get to providing you with an appropriate solution.

Kind Regards,
Ashwin A.K

@momo10 The flow could be like below

  • Read the excel data using read range
  • Filter the values whose column “OK” is not full
  • Loop through each row and check the folder present in the desktop or not using Path exists activity
  • If the folder exists then get the files count

Please find the related workflow below

Example.zip (9.9 KB)

Hi Ashwin
so, first i wanted the robot to search the name folders in orders, when it has found the name folders, then it has to count all the pdfs and write them in excel-table again, but only the rows that do not have “X” in column “OK”.

Hi @momo10 ,

Alright, assuming you only want to mark those folder which exists with “X”, here is a sample workflow →

image

Folder4 does not exist, so I’ve developed it to leave it as blank.

(From row In dt.AsEnumerable()
Let dirExists = Directory.Exists(str_parentFolderPath+"\"+row("Foldername").ToString)
Let res = If(row("OK").ToString.Trim.Equals("X"),
	row("Resultat").ToString, 
	If(dirExists,Directory.GetFiles(str_parentFolderPath+"\"+row("Foldername").ToString,"*.pdf").Count().ToString,""))
Let ra = New Object(){row("foldername"),res,If(dirExists,"X","")}
Select dt_result.Rows.Add(ra)).CopyToDataTable()

Is this what you were looking for?
GetPDFCount_v1.xaml (8.8 KB)

Kind Regards,
Ashwin A.K

Hi Boss,
no i meant if the robot finds the orders then it has to count the PDFs and enter “x”, but if the robot already found an “X” in table then it doesn’t need to count and skip to next line

Did you test the sequence from your end?
I’ve added the logic for whatever you have detailed so far.

ok thank you, i will test the program

I have run the PRogram, but when I try to Write Cell I get this error message (Write Range: Invalid row number (-1) outside allowable range (0…65535))