Leo Susanto <[email protected]> writes:

> On Mon, Oct 17, 2011 at 11:46 AM, Csanyi Pal <[email protected]> wrote:
>> my goal is to get in a directory the following:
>>
>> PIC00001.JPG renamed as Gyermekolimpia_Ujvidek_001.jpg
>> PIC00002.JPG renamed as Gyermekolimpia_Ujvidek_002.jpg
>>  ...
>> PIC00223.JPG renamed as Gyermekolimpia_Ujvidek_223.jpg
>>
>>
>> So far I get this to work:
>>
>> rename -n 's/\w\w\w\w\w/sprintf("Gyermekolimpia_Ujvidek_")/e' *.JPG
>> PIC00001.JPG renamed as Gyermekolimpia_Ujvidek_110.JPG
>>  etc.
>> PIC00223.JPG renamed as Gyermekolimpia_Ujvidek_223.JPG
>>
>> This is good but I want to make the .JPG extensions lowercase.
>>
>> I know that the following command do this:
>> rename -v 's/\.JPG$/\.jpg/' *.JPG
>>
>> but I want to know how to add
>> \.JPG$/\.jpg/
>>
>> into the following command?
>> rename -n 's/\w\w\w\w\w/sprintf("Gyermekolimpia_Ujvidek_")/e' *.JPG

> s/.+(\d{3}).jpg/Gyermekolimpia_Ujvidek_$1.jpg/i

rename -v 's/.+(\d{3}).jpg/Gyermekolimpia_Ujvidek_$1.jpg/i' *.JPG

It works perfectly. Can you explain to me how does it works?

-- 
Regards, Pal
<http://cspl.me>


-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to