home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / question / 12949 < prev    next >
Encoding:
Text File  |  1992-11-05  |  1.9 KB  |  49 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!destroyer!cs.ubc.ca!unixg.ubc.ca!kakwa.ucs.ualberta.ca!acs.ucalgary.ca!cuugnet!edwardsk
  3. From: edwardsk@cuug.ab.ca (Kenneth Edwards 268-6500)
  4. Subject: Re: How to rename a group of files with wild cards (* and ?)?
  5. Message-ID: <1992Nov5.031528.16167@cuug.ab.ca>
  6. Organization: Calgary UNIX Users' Group
  7. References: <1992Oct31.062644.13968@constellation.ecn.uoknor.edu> <1992Nov4.052804.4790@bohra.cpg.oz.au>
  8. Date: Thu, 5 Nov 1992 03:15:28 GMT
  9. Lines: 38
  10.  
  11. In article <1992Nov4.052804.4790@bohra.cpg.oz.au> johnr@bohra.cpg.oz.au (John Reid) writes:
  12. >u235@rex.chb.uokhsc.edu (Yung-Jin Lee) writes:
  13. >
  14. >>Is there anyway to rename a group of files with
  15. >>wild cards (* and ?)?  I've tried mv and cp and
  16. >>I am not able to do this.
  17. >
  18. >To move a group of files called fred* in directory olddir to newdir try
  19. >
  20. >for file in `cd oldir ; ls fred*`
  21. >do
  22. >    mv "$olddir/$file" "$newdir"
  23. >done
  24.  
  25. Well that would work, but I think it is easier.
  26. To move a group of files called fred* in directory olddir to newdir try
  27.  
  28. mv olddir/fred* newdir
  29.  
  30. please tell us what shell you are using so we can give an appropriate
  31. answer, however to rename a group of files in ksh - you do something like
  32.  
  33. for file in fred*.text
  34. do
  35.    mv $file ${file%.text}.txt     # renames all .text files to .txt
  36. OR mv $file f.${file#project}     # renames all fred*.text files to f.*.text
  37. OR mv $file `echo $file | tr "[a-z]" "[A-Z]"` # renames all fred* to FRED*
  38. OR mv $file `expr $file 'fred\(.*\)\.text'`   # quite probably does bad stuff
  39. OR whatever you should probably check first by generating the names before
  40. you do the rename and using an echo in front of the mv until you like the
  41. list of names you get 
  42. done
  43.  
  44. -- 
  45. _____________________________________________________________________________
  46. Feeling amorous, she looked under the sheets and cried, OH NO it's micro soft
  47.  
  48.  
  49.