Sftp download directory while excluding files with certain extension

Did you consider usind rsync (if you have it available)? It supports an --exclude option, where you can specify what you wish to exclude:

rsync -av foo@remotehost:/dir/ /localdir/ --exclude .ipa --exclude .ipa.*