#!/bin/bash

### this is a klunky script to strip dos carraige returns out 
### of files
### argument 1 should be the directory to start the recursive
### stripping
### argument 2 should be the directory you want to put the 
### modified files in
### prichards 8/14/2001

function stripm
{
    echo 'working on directory: '
    echo $1
    
    if [ ! -d $2/$1 ]
    then
       echo 'creating modify directory: '
       echo $2/$1
       mkdir $2/$1
    fi
    for i in $(ls $1)
    do
       if [ $? -eq 0 ]
         then
         if [ -d $1/$i ]
           then
           if [ ! -d $2/$1/$i ]
           then
             mkdir $2/$1/$i
             ## recursive strip call ##
             stripm $1/$i $2
           fi
         fi
         echo 'stripping nasty control characters...'
         sed -e s/// < $1/$i > $2/$1/$i
         echo 'success: ' $2/$1/$i   
       fi    
    done
}

## main... ##
stripm $1 $2


