[OOZY] Renaming more than 200 pics

Charles E "Rick" Taylor IV rick at rickandpatty.com
Sun May 7 19:42:38 UTC 2006


On Sun, 2006-05-07 at 21:58 +0300, OOzy Pal wrote:
> On 5/7/06, gborzi <ulist at gs1.ubuntuforums.org> wrote:
> >
> > Try this
> > > for i in *\ *; do newname=`echo $i|sed -e 's/ /-/g'`; mv "$i" $newname;
> > > done
> >
> >
> > --
> > gborzi
> >
> > --
> > ubuntu-users mailing list
> > ubuntu-users at lists.ubuntu.com
> > https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
> >
> 
> Thank you; it worked. Now the names also contains "(" and ")"  for
> example, a name of file is like:
>  20051030-Layan-(2).jpg
> as you can see the dashes is OK. Now, I want to remove "(" and ")"
> because linux will also put a backslash b4 the "(". Moreover, if the
> number is one digit I want to add a leading 0 so the name becomes
> 20051030-Layan-02.jpg.
> 
> I tried the following but no help
> for i in *\(*; do newname=`echo $i|sed -e 's/ /-/g'`; mv "$i" $newname;
> 
> I got the following error:
> mv: `20060124-Layan-(2).jpg' and `20060124-Layan-(2).jpg' are the same file

You also need to change the "sed" part, which is the part of this little
script that actually makes up the new name.  How about

for i in *\(*; do newname=`echo $i|sed -e 's/(/-/g'`; mv "$i" $newname;
done

and

for i in *\)*; do newname=`echo $i|sed -e 's/)/-/g'`; mv "$i" $newname;
done

There are probably more efficient ways to do this, but the above
works. :)

-- 
--------------------------------------------------------------------
*  Charles E. "Rick" Taylor, IV <rick at rickandpatty.com>
--------------------------------------------------------------------
*  Web: http://www.rickandpatty.com
* Blog: http://shrimpandgrits.rickandpatty.com
--------------------------------------------------------------------






More information about the ubuntu-users mailing list