Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Now Microsoft Free - Some General Questions

0 views
Skip to first unread message

Bruce Burhans

unread,
Nov 30, 2002, 3:57:52 PM11/30/02
to

[...]

> 6.) Mass re-name files: The best for last :). I'm not a programmer, but
> I've been trying to figure out a string that will rename all the files &
> directories in a directory. Right now, files & directories are a mix of
> cases - I'd like to have everything be lower-case. For example:
>
> FOOBAR.txt -> foobar.txt
> Foo.txt -> foo.txt
> foofoo.txt -> foofoo.txt
> Foo_tOO.txt -> foo_too.txt
>
> Can someone give me a hint as to how this can be done (if at all?).


$ for f in * ; do mv $f $( echo $f | tr A-Z a-z )
; done


That's all one line.

HTH


Bruce
--
Bellingham Washington USA
bburhan1 [ AT] earthlink [ DOT] net

>
> Thanks - Thanks - Thanks - Thanks!
>
>
> Thanks, B0G
> ==============
>

> [1] Does VMware count? I still have a usb scanner & cd burner that only
> work under windows. I'll have to use VMware until I can replace them with
> better hardware.
>
>

Chris F.A. Johnson

unread,
Nov 30, 2002, 8:57:20 PM11/30/02
to
On Sat, 30 Nov 2002 at 20:57 GMT, Bruce Burhans wrote:
> [...]
>
>> 6.) Mass re-name files: The best for last :). I'm not a programmer, but
>> I've been trying to figure out a string that will rename all the files &
>> directories in a directory. Right now, files & directories are a mix of
>> cases - I'd like to have everything be lower-case. For example:
>>
>> FOOBAR.txt -> foobar.txt
>> Foo.txt -> foo.txt
>> foofoo.txt -> foofoo.txt
>> Foo_tOO.txt -> foo_too.txt
>>
>> Can someone give me a hint as to how this can be done (if at all?).
>
>
> $ for f in * ; do mv $f $( echo $f | tr A-Z a-z )
> ; done
>
> That's all one line.

Which will fail if any file names contain spaces (or other problem
characters).

Which will generate error messages if the name is already lower
case (as in one of the examples).

Which will cause problems if another file already exists with the
name in lower case.

The first problem is easy to fix; just quote the file names:

mv "$f" "$( echo $f | tr A-Z a-z )"

The second isn't hard, but it's more than you would want in a
single line:

newname=$( echo $f | tr A-Z a-z )
[ "$f" != "$newname" ] && mv "$f" "$( echo $f | tr A-Z a-z )"

The third requires a decision on what to do if a file with the new
name already exists. Do you want to overwrite it? Rename it? Leave
it as is?

[ "$f" != "$newname" ] &&
if [ -e "$newname" ]
then
## what goes here depends on the decision mentioned above.
else


mv "$f" "$( echo $f | tr A-Z a-z )"

fi

--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2002, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License

Bruce Burhans

unread,
Nov 30, 2002, 10:15:29 PM11/30/02
to

"Chris F.A. Johnson" <c.f.a....@rogers.com> wrote in message
news:asbq9v$pfsil$1...@ID-136730.news.dfncis.de...


> On Sat, 30 Nov 2002 at 20:57 GMT, Bruce Burhans wrote:
> > [...]
> >
> >> 6.) Mass re-name files: The best for last :). I'm not a programmer,
but
> >> I've been trying to figure out a string that will rename all the files
&
> >> directories in a directory. Right now, files & directories are a mix
of
> >> cases - I'd like to have everything be lower-case. For example:
> >>
> >> FOOBAR.txt -> foobar.txt
> >> Foo.txt -> foo.txt
> >> foofoo.txt -> foofoo.txt
> >> Foo_tOO.txt -> foo_too.txt
> >>
> >> Can someone give me a hint as to how this can be done (if at all?).
> >
> >
> > $ for f in * ; do mv $f $( echo $f | tr A-Z a-z )
> > ; done
> >
> > That's all one line.
>
> Which will fail if any file names contain spaces (or other problem
> characters).
>

Yes. But from the examples it looked like a well-made directory.

> Which will generate error messages if the name is already lower
> case (as in one of the examples).
>

So what?

> Which will cause problems if another file already exists with the
> name in lower case.
>

Bet it doesn't, judging from the example he showed.


> The first problem is easy to fix; just quote the file names:
>
> mv "$f" "$( echo $f | tr A-Z a-z )"
>
> The second isn't hard, but it's more than you would want in a
> single line:
>
> newname=$( echo $f | tr A-Z a-z )
> [ "$f" != "$newname" ] && mv "$f" "$( echo $f | tr A-Z a-z )"
>
> The third requires a decision on what to do if a file with the new
> name already exists. Do you want to overwrite it? Rename it? Leave
> it as is?
>
> [ "$f" != "$newname" ] &&
> if [ -e "$newname" ]
> then
> ## what goes here depends on the decision mentioned above.
> else
> mv "$f" "$( echo $f | tr A-Z a-z )"
> fi


Nice of you to show him how to deal with all these
eventualities, but I'll bet you my script works just
fine for him. And I doubt that a few error messages wil kill him.

Bruce
--
Bellingham Washington USA
bburhan1 [ AT] earthlink [ DOT] net

>

Chris F.A. Johnson

unread,
Nov 30, 2002, 11:16:36 PM11/30/02
to
On Sun, 01 Dec 2002 at 03:15 GMT, Bruce Burhans wrote:
>
> "Chris F.A. Johnson" <c.f.a....@rogers.com> wrote in message
> news:asbq9v$pfsil$1...@ID-136730.news.dfncis.de...
>> On Sat, 30 Nov 2002 at 20:57 GMT, Bruce Burhans wrote:
>> > [...]
>>>> 6.) Mass re-name files: The best for last :). I'm not a programmer, but
>>>> I've been trying to figure out a string that will rename all the files &
>>>> directories in a directory. Right now, files & directories are a mix of
>>>> cases - I'd like to have everything be lower-case. For example:
>>>>
>> >> FOOBAR.txt -> foobar.txt
>> >> Foo.txt -> foo.txt
>> >> foofoo.txt -> foofoo.txt
>> >> Foo_tOO.txt -> foo_too.txt
>> >>
>> >> Can someone give me a hint as to how this can be done (if at all?).
>> >
>> > $ for f in * ; do mv $f $( echo $f | tr A-Z a-z )
>> > ; done
>> >
>> > That's all one line.
>>
>> Which will fail if any file names contain spaces (or other problem
>> characters).
>
> Yes. But from the examples it looked like a well-made directory.

You have to remember that what is posted is only an illustration,
not what is actually in the directory.

>> Which will generate error messages if the name is already lower
>> case (as in one of the examples).
>
> So what?

So it's sloppy programming.

It's an ERROR messsage; it means you made a mistake; that's never
good.

If you make a habit of accepting error messages that should have,
and easily could have, been prevented, you can get into bad
habits, and ignore messages when they are important.

>> Which will cause problems if another file already exists with the
>> name in lower case.
>
> Bet it doesn't, judging from the example he showed.

Maybe not, but you cannot be sure of that.

[snip]

> Nice of you to show him how to deal with all these
> eventualities, but I'll bet you my script works just
> fine for him.

That's quite possible, but when it's so easy, why not do it
properly?

It's also important to remember that there are many people reading
this newsgroup who never post, but will use the examples posted
here. An answer, particularly for a question that crops up as
often as this one, is not only for the poster, but for the lurkers
as well.

> And I doubt that a few error messages wil kill him.

--

Bruce Burhans

unread,
Dec 1, 2002, 1:04:19 AM12/1/02
to

"Chris F.A. Johnson" <c.f.a....@rogers.com> wrote in message

news:asc2f3$phqi6$1...@ID-136730.news.dfncis.de...


> On Sun, 01 Dec 2002 at 03:15 GMT, Bruce Burhans wrote:
> >
> > "Chris F.A. Johnson" <c.f.a....@rogers.com> wrote in message
> > news:asbq9v$pfsil$1...@ID-136730.news.dfncis.de...

[...]


Hard to argue with that, Chris. And I DID copy
your solutions to my script directory. :-)

But don't you just sometimes have to accept
error messages and deal with them like so

2> /dev/null ?


Bruce
--
Bellingham Washington USA
bburhan1 [ AT] earthlink [ DOT] net

>

Chris F.A. Johnson

unread,
Dec 1, 2002, 1:18:09 AM12/1/02
to
On Sun, 01 Dec 2002 at 06:04 GMT, Bruce Burhans wrote:
>
> But don't you just sometimes have to accept
> error messages and deal with them like so
>
> 2> /dev/null ?

So long as you DO deal with them, and know why they might occur,
not just send stderr to /dev/null because there might be an error
message.

Indiscriminate junking of error messages may hide a mistake that
causes your script to do bad things.

An example of where it is appropriate, is when doing a find or
recursive grep that may pass over directories you do not have
permission to examine.

Bruce Burhans

unread,
Dec 1, 2002, 1:34:28 AM12/1/02
to

"Chris F.A. Johnson" <c.f.a....@rogers.com> wrote in message

news:asc9j1$peaj2$1...@ID-136730.news.dfncis.de...


> On Sun, 01 Dec 2002 at 06:04 GMT, Bruce Burhans wrote:
> >
> > But don't you just sometimes have to accept
> > error messages and deal with them like so
> >
> > 2> /dev/null ?
>
> So long as you DO deal with them, and know why they might occur,
> not just send stderr to /dev/null because there might be an error
> message.
>
> Indiscriminate junking of error messages may hide a mistake that
> causes your script to do bad things.
>
> An example of where it is appropriate, is when doing a find or
> recursive grep that may pass over directories you do not have
> permission to examine.

Exactly what I was thinking of ! But those messages always make me think
that something
is wrong, so I usually give up and log in as root
on another tty :-) Their wording is misleading, I think.

Thanks Chris.

Bruce
--
Bellingham Washington USA
bburhan1 [ AT] earthlink [ DOT] net

>

Bill Unruh

unread,
Dec 1, 2002, 12:19:37 PM12/1/02
to
"Bruce Burhans" <no...@nowhere.com> writes:

]"Chris F.A. Johnson" <c.f.a....@rogers.com> wrote in message

]So what?


It is always a good idea to code properly so that it can handle weird
eventualities. He will write a script and then use it a year later on a
system where things bite.
The error messages demand a response. If you try to mv over an existing
file, it asks permission, as it should.

Spicerun

unread,
Dec 1, 2002, 1:10:08 PM12/1/02
to
On Sat, 30 Nov 2002 14:09:49 +0000, B0G revealed:

I'll try to answer what I can...


> But anyway, here are some general questions I've come up with...
>
> 1.) GUI performance: ... I'm not sure if it's just the way Gnome /
> metacity works, or if it has anything to do with using dual video cards.
> I have downloaded & installed the nvdriver from Nvidia for the GeForce
> 4. I'm using the stock tdfx driver for the Voodoo 5. Aside from killing
> all the eye candy in Gnome, are there any other low-level tweaks that
> will improve performance?
> I've experimented with KDE & have noticed similar issues with it (which
> is why I think it might have more to do with dual video cards than with
> the GUI). I'm open to trying other window managers or GUI's if someone
> can recommend something that is easy to install & set up.

If Metacity is what I remember from previous RedHat distros, I'd consider
something else. I run sawfish, but there are other, leaner Window
Managers.

Also, recompiling your kernel, matching it exactly to your machine will
help a lot in performance as well.


> 2.) Gnome & Xinerama: As stated, I'm using Gnome (and unless I can
> find something better, I expect to continue using it). KDE does seem to
> be a little better at dealing with Xinerama & dual displays. Are there
> any hidden settings somewhere that will tweak how Gnome works with dual
> displays? I'm mainly concerned with the placement of dialog boxes -
> they always get drawn smack dab in the middle of the screen, which means
> they span both monitors. I realize that is the normal behavior with a
> single monitor, but find it annoying when using dual displays.
>
>
I'd consider compiling Gnome and KDE straight from gnome.org or kde.org so
that you get rid of Red Hat's funny tweaks, and run the full Desktop as
intended from these organizations. That might help some of your
performance issues.


> 5.) Java: Are there any Linux web browsers that actually work with
> Java?
> I've tried two versions of Mozilla, a version of Netscape Communicator,
> Galleon and Konqueror - all of which either crash or refuse to display
> Java applets. I've RTFM, including the one found here:
> http://plugindoc.mozdev.org/linux.html

Absolutely. First get the latest Mozilla Binary from mozilla.org and
install it (Don't use Red Hat's strange implementation of mozilla). Next
Download the latest Java JDK from http://java.sun.com, and install it.
Lastly, create a softlink from the mozilla plugins directory to the
libjava plugin in the JDK kit (the netscape 6.1 plugin. Remember that
mozilla can run netscape's plugins). Then start/restart Mozilla. The
latest java JDK works just fine for me. The beauty of the Java JDK from
sun is that it has other plugins that work just fine with the other
browsers as well. Read the documentation how to install it in the other
browsers.

DJM

unread,
Dec 4, 2002, 5:41:35 PM12/4/02
to
On 1 Dec 2002, Chris F.A. Johnson wrote:

> On Sat, 30 Nov 2002 at 20:57 GMT, Bruce Burhans wrote:
> > [...]
> >
> >> 6.) Mass re-name files: The best for last :). I'm not a programmer, but
> >> I've been trying to figure out a string that will rename all the files &
> >> directories in a directory. Right now, files & directories are a mix of
> >> cases - I'd like to have everything be lower-case. For example:
> >>
> >> FOOBAR.txt -> foobar.txt
> >> Foo.txt -> foo.txt
> >> foofoo.txt -> foofoo.txt
> >> Foo_tOO.txt -> foo_too.txt
> >>
> >> Can someone give me a hint as to how this can be done (if at all?).
> >
> >
> > $ for f in * ; do mv $f $( echo $f | tr A-Z a-z )
> > ; done
> >
> > That's all one line.
>

> The third requires a decision on what to do if a file with the new
> name already exists. Do you want to overwrite it? Rename it? Leave
> it as is?
>

Your others were good points. This one's probably moot. Seeing as how
they're moving from a Windows system which is case-insensitive, it's
unlikely they'll have FOOBAR.txt and foobar.txt already in the same
directory.

0 new messages