#!/bin/bash # Change these variables to correct paths MONITOR_DIR=~/JDownloader/captchas TMP_DIR=~/JDownloader/sent_captchas SUCCESS_DIR=~/JDownloader/sent_captchas/success FILE_EXT=jpg # Go to captcha directory cd $MONITOR_DIR # List all files with JPG extension COUNT_FILES=$(ls -l *.$FILE_EXT 2> /dev/null | grep ^- | wc -l) # If there are files like those, continue if [ $COUNT_FILES -gt 0 ]; then # Loop all JPG files and move them to the temporary directory for f in *.$FILE_EXT; do mv $f $TMP_DIR done # Go to temporary directory cd $TMP_DIR # Loop all files there again for f in *.$FILE_EXT; do # Send each file in a separate email as an attachment sendEmail -f computer@gmail.com -t you@gmail.com -u "[CAPTCHA] Please solve" -m `date` -a $f -s smtp.gmail.com:25 -xu computer@gmail.com -xp password -q # Move each file sent to success directory mv -f $f $SUCCESS_DIR done fi