#!/bin/bash -e

D="$1"

if ! [  -d "$D" -a -w "$D" ] ; then
 echo $0 : cannot access directory $D
 exit 1
fi
shift

echo INSTALLING TO $D

H=`pwd`

for i in "$@" ; do 
  pushd $i
  echo INSTALLING FROM $i
  for f in *ppd ; do
   if grep -q  MacStandard $f ; then
    echo CONVERTING $f 
    python3 $H/recode-0.1.py  $f > $D/$f
   else
    echo COPYING $f 
    cp  $f  $D/$f 
   fi
  done
  popd
done


# find "$i" -type f -name '*ppd' | \
#    xargs -n1 -i
