Scripting wvText

Stewart Stremler bofh at stremler.net
Mon Jul 11 00:20:58 PDT 2005


begin  quoting Todd Walton as of Sun, Jul 10, 2005 at 10:24:08PM -0700:
[snip]
> You must specify the name of the input file (duh), and the name of the
> output file that it will create.

You can't give it stdin and redirect stdout?

>                                   Well, I have a whole directory full
> of these doc files.  The problem is, wvText doesn't let you just give
> the name of the file to be converted and then intelligently name the
> output "input" plus ".txt".  That would make sense.  wvText requires
> you to specify a name for the output file.  How can I script this to
> do them all?  Maybe something like:
> 
> #!/bin/bash

Why? I don't see any bash-specific stuff going on here. What's wrong
with sh?

> wvText $1 $1.txt

In tcsh, you use stuff like :t and :r to to that. So something like:

foreach i ( /dir/full/of/files/* )
   wvText $i ${i:t:r}.text
end

...does a fine job.

I'm sure there's a similiar construct in bash.  Of course, there's
always dirname and basename and friends...

wvText $1 `basename $1 .doc`.text

-Stewart "I bet zsh has a slick way of doing this as well" Stremler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://www.kernel-panic.org/pipermail/kplug-list/attachments/20050711/a095f8a4/attachment.pgp


More information about the KPLUG-List mailing list