Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!fluke!inc From: inc@tc.fluke.COM (Gary Benson) Newsgroups: comp.unix.questions Subject: Need a file renaming facility Message-ID: <3564@fluke.COM> Date: 26 Apr 88 22:27:23 GMT Sender: news@tc.fluke.COM Lines: 72 Hello, I recently subscribed to this group to see if it's an appropriate place to ask a question I've had for some time now. It seems to be, so here goes: I work in a publications department, and in the nature of our business, we create, rename, and destroy a LOT of files. A typical directory may have many similar file names. Wildcards help in deleting unneeded files, but not in copying or moving them. For example, consider the following files in a directory associated with a technical manual: QT.1.r QT.4.r QT.A.r QT.2.r QT.5.r QT.annotations.r QT.3.r QT.6.r QT.toc.r For information only, the product is called QuickTools, there is one file per section of the manual (1 through 6), one for Appendix A, one for illustration annotations, and the table of contents. In preparing this manual for production, I run a shell script called "prep" that gets rid of extra spacing, intermediate formatting commands, comments and so on, and creates an output file for each input file. Now my directory now looks like this: QT.1.r QT.4.r QT.A.r Qt.1.r.pre QT.4.r.pre QT.A.r.pre QT.2.r QT.5.r QT.annotations.r QT.2.r.pre QT.5.r.pre QT.annotations.r.pre QT.3.r QT.6.r QT.toc.r QT.3.r.pre QT.6.r.pre QT.toc.r.pre Now I want to rename all those ".pre" files to the same name without ".pre". In other words, I want the directory to look like it did when I began, (like separate mv commands, or cp followed by rm *.pre) separate mv and I realize that a smarter shell script could have taken care of this as part of the prepping process, but there are many ways that people in our group wind up with associated files with similar filenames they want to rename all at once. The alternative (separate 'mv' commands for each section) is time-consuming and error prone. What I'm looking for is a general-purpose renaming facility that (I hope) takes wild cards, with this kind of synatax: rename -f QT.?.r.pre QT.?.r -or- rename QT.*.r.pre QT.*.r -or even- rename QT.?.r.pre \#.r (to change QT.1.r.pre to 1.r, etc) Hopefully a -f option would do it without question, -i would ask before blowing away the file of the same name and -i being the default. No -r option! Has anyone invented such a thing? If so, could you send me a copy? If not, can anyone explain a workable approach to doing this? I'd appreciate any help you can give me. ___ Gary Benson -_-_-_-_-_-_-_-_-inc@tc.fluke.com_-_-_-_-_-_-_-_-_-_ Publication Services Ensign Benson, Space Cadet, Digital Circus, Sector R John Fluke Mfg. Co. Inc. _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -- Gary Benson Publication Services -=[ inc : 5367 : 232E ]=-