Re: renaming files via shell script

On 2006-02-23, robert wrote:

I still have one question: I can't get for 'file in "$@"' or 'for
file' to work. I can, however, get for file in "*mpc*" to work (mpc is
what I meant by somefile.

Here's my test case:

echo "in script"
for file in "$@"
echo "in for loop"

I get 'in script' but not 'in for loop' .

The command I run is this, from the directory that has

find . -type f -name "*mpc*" -exec ./ \;

My mistake; I left out {}:

find . -type f -name "*mpc*" -exec ./ {} \;

The files I have are like so (from same dir as

/home/iksrazal/mpc> find .
./bc/01 - Stella By Starlight.mpc
./bc/02 - Autumn Leaves.mpc
./bc/03 - New Waltz.mpc
./bc/04 - Bouncing With Bud.mpc
./bc/05 - 'Round Midnight.mpc
./bc/06 - And Then Again.mpc
./bc/07 - I Thought About You.mpc
./bc/08 - Someday My Prince Will Come.mpc

Now if I change the script to be the following, I get the 'in for loop'

echo "in script"
for file in "*mpc*"
echo "in for loop"

What am I doing wrong?

If you use that, find does nothing at all; you are not using its
output. Use that if you want to process files in the current
directory (and don't use find).

Chris F.A. Johnson, author | <>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence