#!/bin/bash
#
# S. Parkin 2007/05/25
#
# Script to convert the pale-grey carbons and light-green hydrogens in PS files 
# written by Sheldrick's XP (Bruker SHELXTL subprogram) into dark grey and pure 
# black respectively.  It changes the RGB values of colours C6 & C7 (defined in 
# the header of the PS file).  The syntax of the perl commands was found on the 
# web but I can't find it anymore to cite the source.  If anyone knows where it 
# came from please let me know (s.parkin@uky.edu) and I'll gladly reference it.
#
# The script also converts all .ps and .PS files to .pdf by invoking ps2pdf.  

perl -pi -w -e 's/C6 { 0.4 1 0.4/C6 { 0 0 0/g;' *.ps
perl -pi -w -e 's/C7 { 0.6 0.6 0.6/C7 { 0.2 0.2 0.2/g;' *.ps

# S. Parkin 2004/01/20
#
# This script is adapted from one given by J.R. Schmidt in an article on the web 
# http://rustam.uwp.edu/499/shelltmp.html that converts gif files to jpeg files.
# I adapted it to convert postscript to pdf.

 fix() {
 new=$(basename $1 .PS)
 ps2pdf $1 $new.pdf
 echo ``$1 converted from ps to pdf''
 }

for file in $(ls *.PS)
 do
 fix $file
 done

 fix() {
 new=$(basename $1 .ps)
 ps2pdf $1 $new.pdf
 echo ``$1 converted from ps to pdf''
 }

for file in $(ls *.ps)
 do
 fix $file
 done
