Help--Script for renaming multiple files

Help--Script for renaming multiple files

Post by John N » Mon, 05 Aug 1996 04:00:00



I've been trying out a script I found in a book for renaming multiple
files. But it doesn't work and I can't figure out why it doesn't work.
It's my first attempt at analyzing/writing shell scripts. Your help would
be appreciated. The book the script is from is "A practical guide to Unix
System V," 2nd edition, by Mark G. Sobell, 1991, p. 329.

The script (without comments) is:

#!/bin/csh
if ($#argv != 2 ) goto usage
foreach i ( *$1* )
   mv $i 'echo $i | sed -n s/$1/$2/p'
end
usage:
echo "Usage: rn arg1 arg2"
exit 1

I'm trying to run it under Linux 1.2.13.

--
*---------------------------------------------------------------*
* John New                                                      *

*---------------------------------------------------------------*

 
 
 

Help--Script for renaming multiple files

Post by Rich K » Mon, 05 Aug 1996 04:00:00



>I've been trying out a script I found in a book for renaming multiple
>files. But it doesn't work and I can't figure out why it doesn't work.
>It's my first attempt at analyzing/writing shell scripts. Your help would
>be appreciated. The book the script is from is "A practical guide to Unix
>System V," 2nd edition, by Mark G. Sobell, 1991, p. 329.

>The script (without comments) is:

>#!/bin/csh
>if ($#argv != 2 ) goto usage
>foreach i ( *$1* )
>   mv $i 'echo $i | sed -n s/$1/$2/p'

          ^                          ^

Quote:>end
>usage:
>echo "Usage: rn arg1 arg2"
>exit 1

>I'm trying to run it under Linux 1.2.13.

    this script is not the one you really need. one of the problems you
        are having is using single quote instead of grave accent `.

        richk

>--
>*---------------------------------------------------------------*
>* John New                                                      *

>*---------------------------------------------------------------*


 
 
 

Help--Script for renaming multiple files

Post by era erikss » Wed, 07 Aug 1996 04:00:00


[This message was sent by private mail as well as posted to Usenet]


comp.unix.shell, comp.unix.questions:
 > The script (without comments) is:
(How helpful) ^^^^^^^^^^^^^^^^^^

 > #!/bin/csh

There are a number of reasons why you should not use Csh. Read the FAQ.

 >    mv $i 'echo $i | sed -n s/$1/$2/p'
            ^                          ^
Looks like these are supposed to be backquotes. ` is different from '
-- the book you're using can hopefully tell you how exactly.
Otherwise, read the sh manual, or get another book ;-)

Hope this helps,

/* era */

--
See <http://www.ling.helsinki.fi/~reriksso/> for mantra, disclaimer, etc.
* If you enjoy getting spam, I'd appreciate it if you'd register yourself
  at the following URL:  <http://www.ling.helsinki.fi/~reriksso/spam.html>

 
 
 

1. Bash script to rename multiple files needed

Hi there,

I have to solve the following problem (already consulted 3 books!):

In a certain directory there are several files and some of them have
spaces in their file names. Since I cannot send those files to the lpd
(putting them into quotation marks does not help it) I have to rename all
of them which have those spaces (derived from MacOS default :( ) to a name
with, let's say, a hyphen instead of them.

Any suggestions?

Thanks in advance, Martin.

--

13156 Berlin - Germany
Phone / Fax  +49 / 30 / 477 555 49  

2. $$$$ DO YOU HATE YOUR JOB?? $$$$

3. a tcsh script that rename multiple files

4. ttysnoop installation

5. Multiple File Rename Script?

6. How to pass data to a Unix command?

7. NEWBIE: Help with script to rename files!

8. Query on signal

9. need help with shell script to rename files

10. Help on Script to Rename File Please

11. Help using awk and bash script to copy and rename lots of index.htm files

12. Renaming Multiple Files

13. rename multiple files