I'm developing a Bash script that takes all the images I have in the folder and adds a random string before the extension. That random string would be different for each file.
The images are something like "01.jpg", "02.jpg" ... And the idea would be that when running this command they become "01- (randomstring) .jpg", "02- (randomstring) .jpg ", etc. Ex: 01-9FbdHbpitN.jpg
- 01.jpg → 01-9FbdHbpitN.jpg
This is what I have so far:
for f in *.jpg; do printf '%s\n' "${f%.jpg}abcd.jpg"; done
But just add "abcd" at the end and I would like to be able to change that "abcd" to a self-generated hash, any random string. How could I do it?