Get folder names in directory

hi,

I’m trying to get folders name from a directory and then opnen file from specefic folder with a specefic name

Hi @abdel,

Kindly check an example attached.
Main.xaml (10.7 KB)

1 Like

image

my aims is to open a file from a folder with a specefic name:

for exemple: if the folder name contain “invoice” then go to the folder and then open the pdf file included in it

2 Likes

In this case, I would suggest you to use the If activity instead of using Switch.

Main.xaml (11.7 KB)

image

Or you can filter the folders before getting the files just like that:
image

1 Like

thank you,

i want to avoid using if many times i had 20 folder, i think using switch activity is good way but how

In order to use the switch activity you would have to be sure of the folder name since it’s not possible to have logic inside the switch case and that’s why I suggested to use the If activity. However, what you can do is to create a List of string which contains the words that you expect and than use the .Contains method.

lstWords = New List(Of String) From {"invoice", "teste"}

Directory.GetDirectories(initialFolder).Where(Function(x) lstWords.Contains(x.ToLower))
1 Like

thank you, did you tested it?

i have the following problem:
image

cannot convert object to string

1 Like

Hi @abdel,

  1. Check if your arr2folder variable is of Array(Of String) type
  2. In your For Each activity property check if the type is set to object and change it to string, otherwise you would have to cast your variable to string, something like that:
    file.ToString
1 Like

He is correct otherwise still doubt then check this attached sample: abdel_sample_2.xaml (3.0 KB)

Regards…!!
Aksh

2 Likes

it works, but i still not convinced about the “if” methodology i’m trying switch one:
image

cas “invoice”, “teste”…

1 Like

what do you wants with switch let me know :slight_smile: i m not aware with all above thread.

going through all folder inside a directory
then for each a liste of folder names (“invoice1”, “invoice2”, “invoice3”) open pdf files that are stored in and then get information from them “get text”

1 Like

Hi @abdel,

What you can do is to use a For Each activity and inside it use your switch.

Please share your xaml, so I can help you properly.

1 Like

here it is:

the goal is with an email received with many attachement, stor the attachement in different file (attachement name), the open them and get information from themread_email_invoice.xaml (60.1 KB)

1 Like

@acaciomelo will take care… :slight_smile: have to go @abdel
:slight_smile:

1 Like

Hi @abdel,

Kindly check it again.

read_email_invoice.xaml (64.8 KB)

1 Like

thank you, but it still not working, it open the two pdf but without extracting the informaion!

but the problem is not here, what is needed is:

-save the attachement in different folders depending on their name.
-open separatly each file from each folder to extract the information, here i use scrape relative

hello, the following code, is working finewith one attached file, but when two or more files it just open the adope DC without opening the files:
i’m using acrobat DC

read_email_invoice.xaml (63.3 KB)

1 Like

what error or alert you are getting with that file? will you share that attachment name here?

1 Like

the result in not fine, it does not open the two document i had received by email,

the flow is supposed to get attachment from emails.

save attachement in folders
then open pdf from each folder in a separate window to extract information

1 Like