Iterate through Folder won't break (or exit loop)

I setup a for each loop to get me images that are inside of a specific folder.
However, I do not want to get all the images inside of the folder, I only want a specific amount of images.

So i setup the following sequence:
Capture

The problem is, it still for some reason gets me every single image inside the file, despite my if condition (with the break in it).
Did I set this up properly?
Or am I supposed to be doing it in a different way?

@Sami_Syed

Please follow below steps:

  1. Read all files from folder using Directory.GetFiles(ā€œFolderPathā€) and store result in string array variable and say ā€˜Folderā€™
  2. Declare two interger variables like ā€˜iā€™ and ā€˜countā€™ and initialize values 1 and 5 respectively.

Assign i = 1
Assign count = 5
Note: Change ā€˜countā€™ variable value to how many no. files you want to read from folder.

  1. Then iterate string array using ForEach loop

            ForEach item in Folder
                    IF i < count
                    Then move file
                     i = i +1
                     Else
                     Break
          End loop
    
3 Likes

@Sami_Syed

If the above solution works for you then close this thread by marking it as solution.

Yes I just implemented it today and it worked. Thank you so much!

1 Like

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