Rename files using math operations
This should do the trick. If you do not want the leading zero you can remove sprintf
as well as the "%03d"
format string. Furthermore, if the files to be renamed will always begin with a
, you can also supplant the leading regex [a-zA-Z]*
with the literal character a
. Lastly, although the *
file specifier may be adequate, I would recommend tacking on an extension as an additional safety precaution (e.g. *.png
).
As always, try it out first using the
-n
flag to verify the rename is correct.
rename -v 's/([a-zA-Z]*)([0-9]*)/$1.sprintf("%03d",$2+10)/e' *