title: How to get an array of .png files in a folder using Bash
body: <p>Hi I am a newbe to bash programming and need some help. I am building a pipeline for image processing. I would like to be able to take the png images in a folder and pass them to clusterImage.pl once that is done I would like to then pass the outputted file to seperateObjects.pl the outputted file is of the same name but has kmeansOutput.all.matrix attached to the end. Below is what I have so far, but it is not working. 
  Any help would be greatly appreciated. Thank you</p>
  
  <pre><code>#!/bin/bash
  #This script will take in an image and a matrix file.
  #The output will be an image and a matrix file.
  
  list=`ls *.png`
  for i in $list
  do
  $file="./$list"
  $image_array = $list
  echo $file
  #Cheching to see if the file exists.
  for((j=0;j&lt;=i;j++))
  do
  if [ -e image_array[j] ]; then
  echo $file
  echo "Begining processing"
  #Take in an image and create a matrix from it.
  perl clusterImage.pl SampleImage.png
  #Take in a matrix and draw a picture showing the centers of all
  #of the colonies.
  perl seperateObjects.pl SampleImage.png.kmeansOutput.all.matrix
  echo "Ending processing"
  else
  echo "There is an issue"
  fi
  done
  done
  </code></pre>