Select Multiple Items From Box

HI.

I want to select the first 10 items in this list of files. The 10th file will not be visible, also this will loop back around after the process is finishes and there will be a new top 10 files i want selected.

How can this be done?

Thank you,

1 Like

Hi @MarkC1500

I think thus can be achieved with Directory.GetFiles()

You can find a sample snippet for the same in you Studio in loops For each file

Give it a try

Thanks,
Prankur

2 Likes

Hi. Earlier on in my flow I have directory.getfiles(selectedfolder,"*.pdf), then I make an string
(String) TenFiles =String.Join(",",arrFiles.AsEnumerable().Take(10).tolist) of first ten files.
Then back to array - arrTenFilesArray = TenFiles.Split(","c)
Then i move on to each file getting the file name only. Add to collection and make final array.

Basically I end up with a string - c:\users…“files1.pdf” “file2.pdf” etc etc

I thought i could then type these file names into the text box on the page but it limits the amount of characters i can type.

Alternatively i have tried select multiple items using the array with just the ten file names in. So it tries to multi select file1.pdf file2.pdf etc but i get the error below…

1 Like

@MarkC1500
Can you please use this code
String.Join("",Directory.GetFiles(“FolderPath”,“FileType/FIleNameSequence”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )

2 Likes

Where do I use that and what does it do?

1 Like

Hi. Can anyone help?

2 Likes

Hi @MarkC1500,SelectTop10Files.xaml (11.4 KB)
SelectTop10FilesUsingGetFiles.xaml (10.0 KB)

You can achieve this with two methods.

  1. Use Directory.Getfiles and pass that file in place of file name in the Add files window.
  2. Select the first file name in the window and click shft+down to select other files.

Attached workflows for both approaches. Hope it will be helpful.

Hi. Thanks for that.

I have tried both.

  1. Add files window only allows a certain amount of text written in it so is limited, although this is the method I’m using now, 5 files at a time.

  2. This method works for visible items in the add files window, but I want to select 1st, which is fine, and then 10th file which isn’t visible, also if there is only 7 files left I need it to select the 7th

Sorry, just looked at your workflows.

Option 2 Looks good.

Where and how do I assign inIntTotalFiles?
File.count?

Hi. That is great. I figured my last question out

Any way for it to select only files In add files window? As currently if there are folders in there it includes them in selection

Can you help with this issue?

I think we can ignore this. Even though it highlights folder,folder,file,file… it does actually use the first N files. So can love with that

I have encountered a problem with the second option.

Processing a folder with multiple files. All but one of the file names start with “DD…” one of them starts with “The…”. When tabbing down the add files window it goes straight to the bottom where the “the…” file is. If I change the name of that file to start with “DD…” it tans down the list as it should.

Any thoughts? If I manually change the alphabetical order during the process it then tabs down the list. Not sure why it is applying reverse alphabetical selection here.

Fixed by using sendwindowsmessage for the tab actions

Hi Madhavi

Any way for it to select only files In add files window? As currently if there are folders in there it includes them in selection

This is still a problem actually. If there is only 1 file in the directory and also other folders it will select only the top item. Which is a folder. Any thoughts?

Thank you

@Madhavi

Then use the first option. That gives only files and not folders.
If you still want to proceed with second approach, you can filter the folder if you know the file type.

@MarkC1500 When you say 1st, 10th or 7th file, how you are doing selection? Do you have a logic onto which files to select? In your earlier post, you have mentioned that top 10 files you want to select.

@Madhavi

Thank you.

For option 1 I had logic to get only 10 files from original directory and then type them into the add files window, but this will just not work as I can only type a certain amount of characters into the box.

Filtering the search results should be an easy fix. I will try when I’m back on the pc.

Thanks again

2 Likes