#!/bin/bash
# [photos2eps]

# converts all the *.png and *.jpg files in the directory to eps files 
# with the  extension *.eps
# copies originals to ORIGINALS/

# first eliminate the old ORIGINALS/ because if repeat
# one obtains nested ORIGINALS/!

rm -fR ORIGINALS/

# eliminate the extensions with capital letters
# no loop for rename
   rename  .PNG  .png  *.PNG
   rename  .JPG  .jpg  *.JPG

# new originals
mkdir ORIGINALS/
cp * ORIGINALS/

# first png files 
for img in `ls *.png`
do
   convert $img $img.eps
done

# second jpg files 
for img in `ls *.jpg`
do
   convert $img $img.eps
done   

# now eliminate the unwanted  ¨png¨  &  ¨jpg¨
   rename .png.eps           .eps      *.png.eps
   rename .jpg.eps            .eps *    *.jpg.eps

# remove all the .jpg, .png 
mv -f  *.jpg  ORIGINALS/
mv -f  *.png  ORIGINALS/


# as a check,  we list the files
ls