I want to import to my python script all the jpg images from a specific directory however not all at once but 500 images at each time.

One possible solution is the following:

```
from glob import glob

i = 0
batch= 500
# Read images from file
for filename in glob('Directory/*.jpg'):
    i = i + 1
    if i % batch == 0:
        # apply an algorithm with this data-batch #

```

Is this correct?

Is there any more efficient way to do this?