How change this string:
find . -type f -name "*.jpg" | while read i; do convert "$i" -resize 50% "${i%%.jpg*}_tn.jpg"; done
to make tn_FILENAME.jpg files, not FILENAME_tn.jpg
Thank you!
find . -type f -name "*.jpg" | while read i; do [[ "${i##*/}" =~ ^tn_ ]] || convert "$i" -resize 50% "${i%/*}/tn_${i##*/}"; done
You mean like this?
${i%/*} is the filename stripped of everything following the last dash (so the dir in which the file is located).
/tn_ adds the tn_ prefix to the file, and
${i##*/} strips everything from the file before the last dash (so it's the filename).
Paste these three together and you get your result.
"${i%/*}/tn_${i##*/}"grep -v tn_* when you want to run the command again after new files in the folders.