ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/rename
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (8 years, 1 month ago) by gpertea
File size: 571 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 ##!/usr/local/bin/perl
3
4 # Usage: rename perlexpr [<filemask>]
5 #
6 # e.g. rename 's/\.bak$//' *.bak
7 # rename '$_ .= ".bak"' *
8 # rename 's/$/.bak/' *
9 # rename 'tr/A-Z/a-z/' *
10 # find . -print | rename 's/readme/README/i'
11 # find . -print | rename 's/$/.old/ if -M $_ > 0.5' ??
12 #
13
14 ($op = shift) || die "Usage: rename perlexpr [filenames]\n";
15
16
17 if (!@ARGV) {
18 @ARGV = <STDIN>;
19 chop(@ARGV);
20 }
21 for (@ARGV) {
22 $was = $_;
23 eval $op;
24 die $@ if $@;
25 if ($was ne $_) {
26 print "rename $was to $_\n";
27 rename ($was,$_)
28 }
29 }

Properties

Name Value
svn:executable *