Re: [Help] Renaming files through bash shell scripts

Baskar Selvaraj <baskar-FaTCxNPFk8w/[email protected]>
Newsgroups gmane.org.user-groups.linux.ilugc
Message-ID <CACtiFJZvAb5JPCHhpTpT_4oMw6NOdKOa5b=fZrZtuF3pdrgv=Q@mail.gmail.com>
On 10/28/15, Vinoth Marimuthu <[email protected]> wrote:
> Hi Baskar,
>
> you can try this
>
> i=1
> cd *test*
> for name in `ls | sort`;
> do
> temp=`echo $name | cut -c 1-3`;
> if [ $i -lt 10 ]
> then
> newname=$temp;
> newname+="0$i.mp4";
> echo $name renamed to $newname;
> mv $name $newname
> else
> newname="$temp$i.mp4";
> echo $name renamed to $newname;
> mv $name $newname
> fi
> i=$((i+1));
> done
> cd ..
>
> change it to directory you want.
>

Thanks, it worked.

S. Baskar
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.