Running batches of files at a time from a script

Hi

I have a script that performs a process on a file.

I want to know how to include a function to run a batch of files?

Here is my script

 
#!/bin/bash
#---------------------------------------------------------------------------------------------------------------------- 
#This script allows the user to import a dsx file 
#
# Usage:
#./import.sh -s -d -r -o -f
#
#-----------------------------------------------------------------------------------------------------------------------
dbname="$dbname"
dsn="$dsn"
dsxfile="$dsxfile"
oprange=""
norule=""
verbose=""
reverb=""
module=`basename $0`
DSXLOG_MODULE=$module; export DSXLOG_MODULE
dsxdir="/var/local/dsx/import"
dsximp="/usr/local/bin/dsximp.exe"
dsxpids="/var/run/"
importdir="/var/local/bin/Automated_Testing/Auto_Scripts"

I wrote something like this:

function batch
{
for dsxfile in $dsxdir/*
do
$dsximp $norule $oprange --dsn=$dsn --dbname=$dbname --user=datasafe --password=datasafe --dsxfile=$dsxdir/$dsxfile
done
 
}
function displayHelp()
{
echo ""
echo " Usage: ./import.sh [ -s -d -r -o -f ]"
echo ""
echo " -s, --dsn identified by the Data Source Name "
echo " -d, --dbname Identified by the Database Name "
echo " -r, --norule Do not excecute dsxrule " 
echo " -o, --oprange Use optimize range checking " 
echo " -f, --dsxfile Identified by the file in dsx format "
echo " -b, --batch Runs the import for a batch of files "
echo " -h, --help Identified by the help menu "
echo ""

}
if [ -e ${dsxpids}$module.pid ] 
then
dsxlog $reverb --warning --module="$module" " pid = $$ : Is already running"
true
exit;
else
dsxlog $reverb --info --module="$module" "started pid = $$" 
while getopts " s: d: r o f: b e h " option
do
case $option in

f ) dsxfile="$OPTARG";;
d ) dbname="$OPTARG";;
s ) dsn="$OPTARG";;
r ) norule="-r";;
o ) oprange="-O";;
e ) verbose="--verbose";
reverb="--echo";;
b ) batch;;
h ) displayHelp;
dsxlog $reverb --info --module="$module" "displaying --helpmenu";
dsxlog $reverb --info --module="$module" "ended, pid = $$";
exit;;
? | * )displayHelp;
dsxlog $reverb --info --module="$module" "invalid option entered --see helpmenu ";
dsxlog $reverb --info --module="$module" "ended, pid = $$";
exit;;

esac;
done
if [ $# -eq 0 ]; then
displayHelp
dsxlog $reverb --info --module="$module" "no options have been entered --see helpmenu"
dsxlog $reverb --info --module="$module" "ended, pid = $$" 
exit 1
fi
 
$dsximp $norule $oprange --dsn=$dsn --dbname=$dbname --user=datasafe --password=datasafe --dsxfile=$dsxdir/$dsxfile
dsxlog $reverb --info --module="$module" "ended, pid = $$" 
fi
 
 

are u getting any errors??

Not errors, but it isn't performing the function I would like it to do.

It doesn't read the files....