#!/bin/bash

walk_dir () {    
    shopt -s nullglob dotglob
    for pathname in "$1"/*; do
        if [ -d "$pathname" ]; then
            walk_dir "$pathname"
        else
            case "$pathname" in
                        *.png|*.jpg)
                    docker run -ti --rm -v "$pathname":/myfile acleancoder/imagemagick-full convert /myfile -background white -alpha remove -alpha off /myfile
                    img2pdf --output "$pathname.pdf" "$pathname"
                    #printf '%s\n' "$pathname"
                    chmod -R 777 /mnt/user/Inbox/evernote
            esac
            sendEmail -f me@noxs.me -t sinedbret.77bce@m.evernote.com -s 192.168.10.222:2525 -u "$pathname" -m "$pathname" -a $pathname
        fi
    done
}

mydir=/mnt/user/Inbox/evernote

walk_dir "$mydir"