We have a winner!
At first I thought the IFS didn't work; then I realized that I was
saving to one test script, and running an older one! (whoops)
Works like a charm. Not sure I fully understood the explanation; I'm
going to google it in a minute.
I also figured out I misread the unzip man file, and that I was
looking for the -j modifier (to junk the folder structure of the
archive) not -d!
Fini. It works. And I've learned a lot; backticks and IFS, putting $i
in "", using case in shell scripts, using find at all, and the
challenge of spaces in *nix.
Thank you for everyone who put in a piece and spoke up. For the
record, I'm running Ubuntu (breezy) 64-bit, GNOME desktop, and I've
thrown a couple of the scripts (much much smaller ones) in the
/home/user/.gnome2/nautilus-scripts directory. It shows up when you
right click! Very handy for the combined use of the GUI desktop and
custom scripting.
Goodnight & God bless
-jordan
The final script(s)
The Viewer: to see what is actually going to be operated on
#!/bin/bash
IFS="
"
for i in `find . -name '*.tar' -o -name '*.rar' -o -name '*.zip'`; do
echo "$i"
done
The Unpacker
#!/bin/bash
IFS="
"
for i in `find . -name '*.tar' -o -name '*.rar' -o -name '*.zip'`; do
case "$i" in
*.tar)
mkdir `basename "$i" .tar`
cd `basename "$i" .tar`
tar xvf ../"$i"
cd ..
;;
*.rar)
mkdir `basename "$i" .rar`
cd `basename "$i" .rar`
unrar e ../"$i"
cd ..
;;
*.zip)
mkdir `basename "$i" .zip`
cd `basename "$i" .zip`
unzip -j ../"$i"
cd ..
;;
esac
done
+++++++++++++++++++++++++++++++++++++++
On 3/14/06, Dave Sherohman <esper at sherohman.org> wrote:
> On Tue, Mar 14, 2006 at 06:34:27PM -0600, Dave Sherohman wrote:
> > I did some quick testing to verify my suggestion this time (I was
> > sure the double quotes should have handled this...) and it should
> > work to set IFS (that's the shell's Input File Separator) at the
> > start of your script, then telling find to use the new separator
> > rather than its default newlines.
>
> Whoops! Ignore the part about changing the separator used by find...
> I wrote that before I figured out how to set IFS to a newline and
> forgot to edit it out until after I'd sent the message... *blush*
>
> --
> The freedoms that we enjoy presently are the most important victories of the
> White Hats over the past several millennia, and it is vitally important that
> we don't give them up now, only because we are frightened.
> - Eolake Stobblehouse (http://stobblehouse.com/text/battle.html)
>
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>