I think I can achieve this by using ExecuteStreamCommand processor and calling a script.
#!/bin/bash
HOST="host"
USER="testuser"
REMOTE_DIR="/files/data"
export PASSWORD="Qwerty@123"
BATCH_FILE=$(mktemp)
echo "spawn sftp $USER@$HOST" > $BATCH_FILE
echo "expect \"password:\"" >> $BATCH_FILE
echo "send \"\$env(PASSWORD)\\r\"" >> $BATCH_FILE
echo "expect \"sftp>\"" >> $BATCH_FILE
echo "send \"ls -l $REMOTE_DIR\\r\"" >> $BATCH_FILE
echo "expect \"sftp>\"" >> $BATCH_FILE
echo "send \"exit\\r\"" >> $BATCH_FILE
expect $BATCH_FILE | sed -n '/sftp>/, /sftp>/p' | grep -v '^sftp>'| awk '$5 < 1000000000 {print $NF}'
rm $BATCH_FILE
this will give output:
$ ./batchfile.sh
names.txt
names2.txt
numlist.txt
some_witherror.txt
maybe increase the size of the attribute length to include larger value. Of course, for this I will have to install expect in my docker image.