Here is one way (put it in a file and execute it with any POSIX shell like bash or ksh):
cd ~/somefolder/ || exit 1 for f in *.png do case $f in (tn_*) continue ;; (*) convert "${f}" -resize 50%x50% "tn_${f}" ;; esac done With modern shells the case construct could also be replaced by a terser conditional command:
cd ~/somefolder/ || exit 1 for f in *.png do [[ "$f" != tn_* ]] && convert "${f}" -resize 50%x50% "tn_${f}" done (But this code is from memory and untested, so inspect the convert command about the actual resize-syntax, and try it in some sample directory on a few sample files first.)