I have to write a shell script that copies all files in the directory subtree and output the files into one file, and all directories into another file.

The arguement passed is the directory my script should start in. I have this, but don't know how to set the arguement and make the script not crash. I know the arguement is stored in '$1' but I dunno where to add "cd $1" or something in this code.

Code:
#!/bin/sh
for i in *; do
        if test -f $i; then
        echo `pwd`/$i >> /gaul/s1/student/2001/rgallard/outfiles.txt
fi
done
for k in *; do
        if test -d $k; then

        echo `pwd`/$k >> /gaul/s1/student/2001/rgallard/outdirs.txt
        cd $k

        /gaul/s1/student/2001/rgallard/prt4.sh
        cd ..

        fi
        done