source: trunk/third/perl/eg/rename @ 10724

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