I want to rename files by appending "-renamed" to the basename before the extension, but I also don't want to rename files that already have the "-renamed" string.
For example,
IMG_1234.jpg -> IMG_1234-renamed.jpg
IMG_1235.mp4 -> IMG_1235-renamed.mp4
IMG_1236-renamed.jpg -> no change
For the first part, I have the following working:
for f in *.jpg; do mv $f ${f%.jpg}-renamed.jpg; done
for f in *.mp4; do mv $f ${f%.mp4}-renamed.mp4; done
How can I assure that subsequent runs won't create keep adding the string over and over?
IMG_1234-renamed.jpg -> IMG_1234-renamed-renamed.jpg
IMG_1235-renamed.mp4 -> IMG_1235-renamed-renamed.mp4