On 23 May 2004 12:10:15 -0700,
() wrote:
>I have some files I want to rename them upon parts of their names .
>For example : files :
>part03_iti_r01_ch03_ver03_conditional_statements_ one_if_TV_Rental_bills.c
>part03_iti_r01_ch03_ver04_conditional_statements_ one_if_else_TV_Rental_bills.c
>part03_iti_r01_ch03_ver05_conditional_statements_ multi_if_else_TV_Rental_bills.c
>part03_iti_r01_ch03_ver06_conditional_statements_ switch_TV_Rental_bills.c
[snip]
>I will convert
>part03_iti_r01_ch03_ver03_conditional_statements_ one_if_TV_Rental_bills.c
>I chose ex^^ & ^^.c
>
>Which utility I can choose for accomplishing thar task ?
>sed,Perl.... How can I use it in a loop?
If your filenames are *really* that regular, then you may use
something like
# ls *.c
[snip list as above]
# perl -e '$"=""; rename $_, "ex@{[(/\d+/g)[2,3]]}.c" for @ARGV' *.c
# ls *.c
ex0303.c ex0304.c ex0305.c ex0306.c
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"