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. I don't really understand your script.
#!/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
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