Reading from Directory

I am trying to make a simple script where you type in a directory, and the script tells you how many directories are within the directory, how many files, and some other general file information. My problem is setting up a for loop to read the info about the files inside the specified directory. For example:

I am the directory: ~/temp
test is in the directory: ~/temp/test

I type:

file.sh test

file=$1  

for file in $file [ ls '*' ]
do

if [ -d $file ]
then
  dirCount=`expr $dirCount + 1`
fi

done

This is my current code, but it does not work. It keeps telling me the information about the directory that I am in, rather than the 'test' directory. Does anyone know why this is happening/how to fix it?

Any help is greatly appreciated.

---------- Post updated at 05:27 PM ---------- Previous update was at 04:48 PM ----------

I have also tried

for file in$(find $1 -iname '*'); do

and

for file in `ls *`

All seem to do the same thing

All of those constructs are going to break down when you have a large number of files since there's a limit to the number of arguments you can cram into a for loop. Also, `ls *` is the same thing as just * anyway. See useless use of backticks and useless use of ls *. Besides, * won't find anything deeper than the immediate directory.

A better way is to read files one by one from a file or stream. Here we save to a temporary file:

TMP=`mktemp`
find "$1" > "$TMP"

DIRCOUNT=0
FILECOUNT=0
while read FILENAME
do
        if [ -f "$FILENAME" ]
        then
                FILECOUNT=$((FILECOUNT+1))
        elif [ -d "$FILENAME" ]
        then
                DIRCOUNT=$((DIRCOUNT+1))
        fi
done < "$TMP"

rm -f "$TMP"

echo "Directories: ${DIRCOUNT}"
echo "Files: ${FILECOUNT}"

#/bin/ksh or bash or ...
cd "$1"
d=0
f=0
# no need to use ls, you can use command line "filename generation", it
# works in every line, test example echo *
for file in *
do
        [ -d "$file" ] && ((d+=1)) && continue
        [ -f "$file" ] && ((f+=1)) && continue
        # more rules ...
done
echo "dir :$d"
echo "file:$f"

In this example you don't need cd, in this case for line will be

for file in "$1"/*