--- /dev/null
+#!/bin/sh
+
+# -- Check Image folders and find out cycle number ---------------------
+
+# -- Get the num of cycles from L001
+if [ ! -d Images/L001 ]
+then
+ echo "ERROR_L001_not_found."
+ exit 127
+fi
+c=1
+while [ -d Images/L001/C$c.1 ] && [ $c -le 36 ]
+do
+ c=`expr $c + 1`
+done
+
+toC_1=`expr $c - 1`
+
+## echo "DUBUG INFO: Found $toC_1 folders in L001"
+
+##--- Now compare each of the other lanes 2 - 8 to C1
+NumCycles=0
+for (( l = 2 ; l <= 8; l++ ))
+do
+ ## echo "lane folder $l"
+ if [ -d Images/L00$l ]
+ then
+ c=1
+ while [ -d Images/L00$l/C$c.1 ] && [ $c -le 36 ]
+ do
+ NumCycles=$c
+ c=`expr $c + 1`
+ done
+ ## Check
+ if [ $NumCycles != $toC_1 ]
+ then
+ echo "ERROR_Num_Of_Cycles_in_$l_is_not_$toC_1"
+ exit 127
+ fi
+ else
+ echo "Img_folder_L00$l_not_found"
+ exit 127
+ fi
+done
+
+tocycle=$toC_1
+echo $tocycle
+exit
\ No newline at end of file