home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / perl-4.036.tar.gz / perl-4.036.tar / perl-4.036 / eg / rename < prev    next >
Text File  |  1993-02-08  |  2KB  |  81 lines

  1. #!/usr/bin/perl
  2. 'di';
  3. 'ig00';
  4. #
  5. # $Header: rename,v 4.0 91/03/20 01:11:53 lwall Locked $
  6. #
  7. # $Log:    rename,v $
  8. # Revision 4.0  91/03/20  01:11:53  lwall
  9. # 4.0 baseline.
  10. # Revision 3.0.1.2  90/08/09  03:17:57  lwall
  11. # patch19: added man page for relink and rename
  12.  
  13. ($op = shift) || die "Usage: rename perlexpr [filenames]\n";
  14. if (!@ARGV) {
  15.     @ARGV = <STDIN>;
  16.     chop(@ARGV);
  17. }
  18. for (@ARGV) {
  19.     $was = $_;
  20.     eval $op;
  21.     die $@ if $@;
  22.     rename($was,$_) unless $was eq $_;
  23. }
  24. ##############################################################################
  25.  
  26.     # These next few lines are legal in both Perl and nroff.
  27.  
  28. .00;            # finish .ig
  29.  
  30. 'di            \" finish diversion--previous line must be blank
  31. .nr nl 0-1        \" fake up transition to first page again
  32. .nr % 0            \" start at page 1
  33. ';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
  34. .TH RENAME 1 "July 30, 1990"
  35. .AT 3
  36. .SH NAME
  37. rename \- renames multiple files
  38. .SH SYNOPSIS
  39. .B rename perlexpr [files]
  40. .SH DESCRIPTION
  41. .I Rename
  42. renames the filenames supplied according to the rule specified as the
  43. first argument.
  44. The argument is a Perl expression which is expected to modify the $_
  45. string in Perl for at least some of the filenames specified.
  46. If a given filename is not modified by the expression, it will not be
  47. renamed.
  48. If no filenames are given on the command line, filenames will be read
  49. via standard input.
  50. .PP
  51. For example, to rename all files matching *.bak to strip the extension,
  52. you might say
  53. .nf
  54.  
  55.     rename 's/\e.bak$//' *.bak
  56.  
  57. .fi
  58. To translate uppercase names to lower, you'd use
  59. .nf
  60.  
  61.     rename 'y/A-Z/a-z/' *
  62.  
  63. .fi
  64. .SH ENVIRONMENT
  65. No environment variables are used.
  66. .SH FILES
  67. .SH AUTHOR
  68. Larry Wall
  69. .SH "SEE ALSO"
  70. mv(1)
  71. .br
  72. perl(1)
  73. .SH DIAGNOSTICS
  74. If you give an invalid Perl expression you'll get a syntax error.
  75. .SH BUGS
  76. .I Rename
  77. does not check for the existence of target filenames, so use with care.
  78. .ex
  79.