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"; |
---|
10 | if (!@ARGV) { |
---|
11 | @ARGV = <STDIN>; |
---|
12 | chop(@ARGV); |
---|
13 | } |
---|
14 | for (@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 |
---|
33 | rename \- renames multiple files |
---|
34 | .SH SYNOPSIS |
---|
35 | .B rename perlexpr [files] |
---|
36 | .SH DESCRIPTION |
---|
37 | .I Rename |
---|
38 | renames the filenames supplied according to the rule specified as the |
---|
39 | first argument. |
---|
40 | The argument is a Perl expression which is expected to modify the $_ |
---|
41 | string in Perl for at least some of the filenames specified. |
---|
42 | If a given filename is not modified by the expression, it will not be |
---|
43 | renamed. |
---|
44 | If no filenames are given on the command line, filenames will be read |
---|
45 | via standard input. |
---|
46 | .PP |
---|
47 | For example, to rename all files matching *.bak to strip the extension, |
---|
48 | you might say |
---|
49 | .nf |
---|
50 | |
---|
51 | rename 's/\e.bak$//' *.bak |
---|
52 | |
---|
53 | .fi |
---|
54 | To translate uppercase names to lower, you'd use |
---|
55 | .nf |
---|
56 | |
---|
57 | rename 'y/A-Z/a-z/' * |
---|
58 | |
---|
59 | .fi |
---|
60 | .SH ENVIRONMENT |
---|
61 | No environment variables are used. |
---|
62 | .SH FILES |
---|
63 | .SH AUTHOR |
---|
64 | Larry Wall |
---|
65 | .SH "SEE ALSO" |
---|
66 | mv(1) |
---|
67 | .br |
---|
68 | perl(1) |
---|
69 | .SH DIAGNOSTICS |
---|
70 | If you give an invalid Perl expression you'll get a syntax error. |
---|
71 | .SH BUGS |
---|
72 | .I Rename |
---|
73 | does not check for the existence of target filenames, so use with care. |
---|
74 | .ex |
---|