SFTP:error while creating folders on remote server

Hi,

I am trying to create some folders on remote server with SFTP connection.
if the folder is exist then it is not executing the next commands.

i.e. if temp/folder is exist then it it not executing
mkdir $folder1
mkdir $folder2 commands.

here is my code.
sftp -b /dev/fd/0 USER@SERVER <<main
binary

mkdir temp/folder
cd temp/folder

echo "creating folders"
mkdir $folder1
mkdir $folder2

bye
main

please can any one help.