using linux's rename utility I have files that are named similar to
kbb.12.06.14.actual_name.jpg
kbb.13.05.13.actual_name.jpg
kbb.11.11.29.actual_name.jpg
and I want to change that to
actual_name.kbb.12.06.14.jpg
actual_name.kbb.13.05.13.jpg
actual_name.kbb.11.11.29.jpg
I know I can get the beginning of a file with
rename 's/^/something/' *
but is there a way to select from the beginning to a certain length in the file? Similar to an array.
The perl regex syntax for selecting the first 13 characters would be this:
s/^.{13}/something/'
Similarly, if you wanted to match the last 13 characters you could use this:
s/.{13}$/something/'
The ^
is an anchor to the beginning of the string and $
is an anchor for the end of the string.