Hello, experts,
I need to rename a lot of files to extracted 7 last letters from original name;
ex. from "zyxhheddbaaa00106.jpg" to "106.jpg"
As the original filename text length varies, it seems that I need to use both "rev" and "cut" command.
To begin with "rev" command, I thought the command below work,
Code:
for f in `find . -name *.*`; do g="$(rev $(basename $f))" | mv $f "$(dirname $f)/$(basename $g)" ; done
However, I got the error message below.
basename: missing operand
Try 'basename --help' for more information.
rev: cannot open zzzhheddbaaa0381.jpg: No such file or directory
mv: './066/zzzhheddbaaa0381.jpg' and './066/zzzhheddbaaa0381.jpg' are the same file
My questions are:
Regarding "basename": I don't understand this error as in the next line it seems that the file name is read correctly.
Regarding "rev": How to reverse the text itself rather than reading a file?
I appreciate your advice, thank you in advance.