{% for batch in batches %}
{% set batch_number = batch[0].split('_')[0] if batch and '_' in batch[0] else 'unstructured' %}
{% for image in batch %}
{% if '_' in image and '.' in image.split('_')[1] %}
{% set index = image.split('_')[1].split('.')[0] %}
{% else %}
{% set index = 'unstructured' %}
{% endif %}
{% endfor %}
{% if not loop.last %}
{% endif %}
{% endfor %}