Mailinglist Archive: opensuse (2358 mails)
| < Previous | Next > |
Re: [SLE] Name Game
- From: bshelton@xxxxxxxxxxxxxx (Brad Shelton)
- Date: Fri, 1 Oct 1999 16:48:02 -0400
- Message-id: <19991001164802.A30100@xxxxxxxxxxxxxx>
On Fri, Oct 01, 1999 at 03:33:58PM +0200, Maurizio Firmani wrote:
> On ven, 01 ott 1999, Jon Pennington wrote:
> > Here's one for you scripting gurus;
> >
> > I have a directory with a bunch of tarballs in it (GTK+ themes, actually).
> > Each of the names is like this:
> >
> > theme-name[1].tar.gz
> >
> > I want the names to be like this:
> >
> > theme-name.tar.gz
> >
> > Can't I write a script that will automatically rename all of the files? I
> > have around 300 of them so far, and I'd really rather not do it by hand :).
> >
>
> This simple script should work for you:
>
> #!/bin/sh
>
> for i in `ls *.tar.gz`; do
> echo "Renaming $i"
> mv $i `echo $i | sed "s/\[.*\]//"`
> done
>
> Give it a name, chmod +x and then execute it.
This will take all *[%].tar.gz files and completely strip the brackets AND
numbers from the file name. So, if you have go-theme[1].tar.gz and
go-theme[2].tar.gz you're gonna delete some files you don't want to.
Maybe it should be:
#!/bin/sh
for i in `ls *.tar.gz`; do
echo "Renaming $i"
mv $i `echo $i | sed -e 's/\[//' -e 's/\]//'`
done
instead?
--
Brad Shelton On Line Exchange http://online-isp.com
--
To unsubscribe send e-mail to suse-linux-e-unsubscribe@xxxxxxxx
For additional commands send e-mail to suse-linux-e-help@xxxxxxxx
Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
| < Previous | Next > |