#!/bin/bash
# chmod 777 cropper.sh
# ------------------------------------------------------------------------------#
# halve files in a folder. files have to be numbered sequentially.
#
# ------------------------------------------------------------------------------
printf "\n\n%-3s----------------------------------------"
printf "\n%-4shalve files in a folder."
printf "\n%-3s----------------------------------------\n\n\n"
# ------------------------------------------------------------------------------
ls pics/
echo which directory \(full path\)?
read diri_
diri_=pics/$diri_
# ------------------------------------------------------------------------------
echo name of base file?
read base_
# ------------------------------------------------------------------------------
echo number of last file?
read last_
# ------------------------------------------------------------------------------
cd $diri_
# ------------------------------------------------------------------------------
counter=1
# ------------------------------------------------------------------------------
for ((i_=2;i_<=last_;i_++))
do 
	if [ `expr $i_ % 2` -eq 0 ]
	then
		rm "$base_$i_.png"
		# echo "$base_$i_.png"
	fi
	# ----------------------------------------------------------------------------
	if [ `expr $i_ % 2` -eq 1 ]
	then
		j_=$((i_-counter))
		mv "$base_$i_.png" "$base_$j_.png"
		# echo "$base_$i_.png" "$base_$j_.png"
		counter=$((counter+1))
	fi
done
# ------------------------------------------------------------------------------
cd ../
# ------------------------------------------------------------------------------
