trying to rename the files in dir

I have bunch of files in win xp machine with

123456 E15 filename
112333.E20 filename
123412.E11 filename

you get the pic, I mount that xp machine's share into linux and try to do a mass rename to something simpler

E15 filename
E20 filename and so on..

I wrote below thinking that it would work but it does not.. can someone advise?

#!/bin/sh
ls |
egrep "^[0-9][0-9][0-9][0-9][0-9]" |
while read a
do
echo $a
yahoo=`sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9][ .]//gi'`
mv $a $yahoo ; mv $yahoo $a
done

yahoo=`sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9][ .]//gi'`

You're not giving sed any input. You need to echo $a into it or something like that. But then it looks like your two mv statement cancel each other. :confused: I don't really understand your script.

Assuming the first filename is 123456.E15 filename and not 123456 E15 filename, with zsh:

autoload -U zmv
zmv '[0-9]*.(*)' '$1'

I guess below is what I try to do.. and does it make sense?

trying to rename a file.. so i guess mv $a $yahoo is ok?

and yes some file has 6 digits following by space or .

#!/bin/sh
ls |
    egrep "^[0-9][0-9][0-9][0-9][0-9]" |
     while read a
      do
         yahoo=`echo $a |sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9][ .]//gi'`
         mv $a $yahoo  
done







Below code seem to work..

070625 kbs1.E41.You.Landscape.kor.hdtv.original.avi

was the original file name I did test on..

#!/bin/sh
ls |
    egrep "^[0-9][0-9][0-9][0-9][0-9]" |
     while read a
      do
         yahoo=`echo $a |sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9][ .]//gi'`
         echo $yahoo
         mv "$a" "$yahoo"
done

Now I am trying to modify that so it will take out kbs1,

other file might have

mbc,sbs,kbs,kbs1 mbc1 mbc2 kbs2 but below did not work

#!/bin/sh
ls |
    egrep "^[0-9][0-9][0-9][0-9][0-9]" |
     while read a
      do
         yahoo=`echo $a |sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9][ .]//gi' | sed 's/^[kms]b[sc][12]?//gi`
         echo $yahoo
         mv "$a" "$yahoo"
done

I think below works.. I guess + is not supported under sed..

I am bit nervous to run below command on folder that I have so many avi files.. I don't want to wreck anything up.. does anyone see any danger?

#!/bin/sh
ls |
    egrep "^[0-9][0-9][0-9][0-9][0-9]" |
     while read a
      do
         yahoo=`echo $a |sed 's/^[0-9][0-9][0-9][0-9][0-9][0-9][ .]//gi' | sed 's/^[kms]b[cs][^.]*\.//gi'`
         echo $yahoo
         mv "$a" "$yahoo"
done


I would first do:

echo mv "$a" "$yahoo"

and then look at the output to be sure. And I would have a backup so I can recover if it fumbles.

rock on guys.. thanks.. I used cautionary measure and it's all working.. now working on next fix..

E41.You.Landscape.kor.hdtv.original.avi

trying to put below files into different names so that
it will look like----> Love.Or.war.E388.avi

Everyone has different name, so I did below but do not work...

#!/bin/sh
ls |
    egrep "^E[1-9][0-9][0-9]*\." |
     while read a
      do
         yahoo=`echo $a |sed '/\(E[^.]\)\.\([^(kor|hdtv|sdtv|avi)]\)[^(.avi)]\(\.avi\)/\2\1\3/gi'`
         echo $yahoo
         mv "$a" "$yahoo"
done

E388.Love.Or.War.kor.hdtv.avi
E389.Love.Or.War.kor.hdtv.avi
E38.Lovely.Goodday.kor.hdtv.avi
E38.The.Happy.Woman.kor.sdtv.avi
E38.You.Landscape.kor.hdtv.avi
E39.The.Happy.Woman.kor.sdtv.avi
E39.You.Landscape.kor.hdtv.avi
E40.The.Happy.Woman.kor.sdtv.avi
E41.The.Happy.Woman.kor.sdtv.avi
E42.Lovely.Goodday.kor.hdtv.avi
E42.The.Happy.Woman.kor.sdtv.avi
E43.Lovely.Goodday.kor.hdtv.avi
E43.The.Happy.Woman.kor.sdtv.avi

not clean.. but just did it below..

if someone can tell me better ways to do it.. please let m know.. also. in chracter class.. why can't ^ group of consecutives words?

#!/bin/sh
ls |
    egrep -i "^E[0-9][0-9][0-9]*\." |
     while read a
      do
         yahoo=`echo $a |sed 's/\.//gi' |
                sed 's/^\(E[0-9][0-9][0-9]*\)\(.*\)\(avi$\)/\2\1\.\3/gi'`
         # E41YouLandscapekorhdtvoriginalavi
         echo $yahoo
         mv "$a" "$yahoo"
done