home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / misc / 3522 < prev    next >
Encoding:
Text File  |  1992-09-07  |  1.4 KB  |  38 lines

  1. Newsgroups: comp.unix.misc
  2. Path: sparky!uunet!utcsri!torn!newshub.ccs.yorku.ca!yorku.ca!rreiner
  3. From: rreiner@nexus.yorku.ca (Richard Reiner)
  4. Subject: Re: How to add a suffix to a bunch of files?
  5. Message-ID: <rreiner.715704103@yorku.ca>
  6. Sender: news@newshub.ccs.yorku.ca (USENET News System)
  7. Organization: York University
  8. References: <1992Sep3.213646.26527@msc.cornell.edu> <JDELL.92Sep4152056@nefertiti.mit.edu> <ellis.715700967@nova>
  9. Date: Sat, 5 Sep 1992 14:41:43 GMT
  10. Lines: 26
  11.  
  12. On Thu, 3 Sep 1992 21:36:46 GMT, dchin@tamar.msc.cornell.edu (David W. Chin) said:
  13.  
  14. >I have occasion to add suffices on a whole bunch of files, like a .1 suffix on
  15. >all files in cat1 (just an example).  What's an elegant way to do it?
  16.  
  17. Easy sh and csh solutions have been given, but it's worth pointing out
  18. that the program mmv (available in all the usual places) excels at
  19. this kind of stuff.  In fact, it is much more general.  For instance,
  20. you can do
  21.  
  22.     mmv '*foo*bar*' '#2fiz#3bat#1#2'
  23.  
  24. The #<digit> expressions in the target name work as you'd expect: #1
  25. is replaced with whatever matched the first '*' in the source, etc.;
  26. and each can be used as many times as one likes.  A very useful tool.
  27.  
  28. So the solution to the present problem, using mmv, is just
  29.  
  30.     mmv '*' '#1.1'
  31.  
  32.  
  33. -- 
  34. Richard Reiner........rreiner@nexus.yorku.ca........416-538-3947
  35.  
  36. Learning, n.  The kind of ignorance distinguishing the studious.
  37.   -- Ambrose Bierce, _The Devil's Dictionary_.
  38.