On Thu, Oct 06, 2011 at 03:35:48PM +0200, Csanyi Pal wrote:
> Hi,
>
> I have a directory with filenames as follows:
>
[cut]
I think what you need is something a little more than just s///. rename
will take any perl expression, which, as the man page says, is expected
to rename $_ (which is a perl special variable)
I would suggest that what you may want is:
rename -n '/PIC(\d+)\.JPG/; $_ = sprintf("PIC%05d.JPG", int($1) + 198)'
What I'm doing there is using the // (a shortcut for the m//) operator
to pick out the number part of the filename (\d stands for digit, +
means "one or more". I then use the sprintf command to reconsitute that
number into the form: "PIC" then a zero-padded, five digit number, then
".JPG", while at the same time adding 198 to the number.
>
> ??
>
> Where can I study perl expressions?
man perlrequick
man perlretut
--
Darac Marjal
Attachment:
signature.asc
Description: Digital signature