Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!samsung!umich!sharkey!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.unix.shell Subject: Re: How to do mv *.xyz *.abc in shell script?? Message-ID: Date: 7 Sep 90 15:00:28 GMT References: <5569@minyos.xx.rmit.oz> <975@ria.ccs.uwo.ca> Sender: news@adi.COM Organization: Applied Dynamics International, Inc.; Ann Arbor, Michigan, USA Lines: 41 In-reply-to: lrb@rrivax.rri.uwo.ca's message of 7 Sep 90 06:53:50 GMT This is from Dan LaLiberte of the University of Illinois at Urbana-Champaign. I've used it for years. The conversion to Bourne-shell syntax should be obvious. Usage is like rename 's/\.xyz$/abc/' *.xyz #! /bin/csh -f #/* Written 7:36 pm May 29, 1988 by liberte@uiucdcsm.cs.uiuc.edu in # uicsrd.csrd.uiuc.edu:comp.sources.d */ # Here is my rename script. # # Dan LaLiberte # liberte@a.cs.uiuc.edu # uiucdcs!liberte # # --- # # rename files with a sed command. File names may have spaces in them. if ($#argv < 2) then echo "Usage: rename sed-command file ..." exit (1) endif set command = "$1" shift set noglob while ($#argv > 0) set name = ($argv[1]) shift set newname = `echo "$name" | sed -e "$command"` if ($status != 0) exit 1 echo "mv -i $name $newname" mv -i "$name" "$newname" end exit 0 # /* End of text from uicsrd.csrd.uiuc.edu:comp.sources.d */ -- Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA Work phone: +313 973 1300 Home phone: +313 677 4386 Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel