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:

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?


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
          End loop


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.