Get folder names in directory


#1

hi,

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


I want to find all the folders inside a folder
#2

Hi @abdel,

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


#3

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


#4

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


#5

thank you,

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


#6

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))

#7

thank you, did you tested it?

i have the following problem:
image

cannot convert object to string


#8

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

#9

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

Regards…!!
Aksh


#10

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

cas “invoice”, “teste”…


#11

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


#12

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”


#13

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.


#14

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)


#15

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


#16

Hi @abdel,

Kindly check it again.

read_email_invoice.xaml (64.8 KB)


#17

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


#18

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)


#19

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


#20

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