Copying Multiple Files

Bob Peirce #305 rbp at investor.pgh.pa.us
Fri May 25 21:35:38 AEST 1990


In article <1990May21.011549.8072 at athena.mit.edu> jik at athena.mit.edu (Jonathan I. Kamens) writes:
>In article <207 at taumetCOM>, steve at taumetCOM (Stephen Clamage) writes:
>|> I don't get it.  Why not just:
>|> 
>|> 	cp   source_directory/foo.*   target_directory
>|> 
>|> Does your script do something the obvious command doesn't do?
>
>  This does not do what the original poster asked.  The poster asked: if
>she has a bunch of filenames with the same basename, e.g. foo.a, foo.b,
>foo.c, foo.d, etc., how would she go about renaming them all to bar.a,
>bar.b, bar.c, bar.d, etc.
>
Here is a start to getting there.  Somebody posted a rename script a
while back that does suffixes; eg, rename *.foo to *.bar.  I suspect it
could be modified to do the above.  Here is the script --

#!/bin/csh
#  script to change suffixes enmasse

if ( $#argv != 2 ) then
	echo "usage: rename from to"
	exit
endif

foreach i ( *.$argv[1] )
	mv $i $i:r.$argv[2]
end

-- 
Bob Peirce, Pittsburgh, PA				  412-471-5320
...!uunet!pitt!investor!rbp			rbp at investor.pgh.pa.us



More information about the Comp.unix.wizards mailing list