Count of file name

Hello uipath users and practicioner ,

I have a issue trying to correct the syntax to match the count value of the file name that contains/starts with “P”.

Please refer to the image below.
Will appreciate your help, stucked for afew weeks.1231233|690x345


Small update i refine the codes but expected this error

@haziqh

You need to check whether any filename startes with p right. Then try below one.

      pFiles [] = Directory.GetFiles("Folder path","P*")

      IF pFiles.Count = 1
      Then file exists
       Else file does not exist
2 Likes

Use Split function by using P as a split condition and use output in UBound to get total occurrence of “P” in a string.This UBound number will give count.

Example:
String1 = “This is the value of the string p and p is main split function”
strArrayValue = Split(String1, “P”)
TotalCount = UBound(strArrayValue)
MsgBox TotalCount

1 Like

How do i differentiate the big and small letters? This helps me alot thanks

1 Like

Ive tried this but its not working


Thanks alot again

@haziqh

In that case, first you have to read all files from directory.

         files [] = Directory.GetFiles("Folder Path") 

And then use For Each loop to iterate one by one file and check below condition in IF activity. Before this loop, declare interger variable and say ‘count’ and initialize count with 0

             ForEach item in files
             IF Path.GetFileName(item).StartsWith("Q")
              Then count = count + 1
               Else nothing

               If count > 0
               Then file exists 
                Else file does not exist
1 Like

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