Reputation: 91
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!
Upvotes: 1
Views: 259
Reputation: 4551
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.
Upvotes: 2