forked from ExchangeBC/devex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy
executable file
·49 lines (42 loc) · 1006 Bytes
/
copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
#
# when plural is just adding an s:
# > copy project
#
# when plural is non-standard:
# > copy fly flies
#
my $from_sl = 'superbasic';
my $from_pl = 'superbasics';
my $from_sc = 'Superbasic';
my $from_pc = 'Superbasics';
# my $from_sl = 'article';
# my $from_pl = 'articles';
# my $from_sc = 'Article';
# my $from_pc = 'Articles';
my $to_sl = $ARGV[0];
my $to_pl = $ARGV[1] || $to_sl.'s';
my $to_sc = ucfirst ($to_sl);
my $to_pc = ucfirst ($to_pl);
my $i;
my @t = ($from_pl, $to_pl, $from_sl, $to_sl, $from_pc, $to_pc, $from_sc, $to_sc);
use File::Find;
`mkdir modules/$to_pl`;
`cp -R modules/$from_pl/* modules/$to_pl`;
find (\&editFileNames, "modules/$to_pl");
sub editFileNames {
if (-f) {
my $o = $_;
my $n = $_;
for ($i = 0; $i < @t; $i+=2) {
$n =~ s/$t[$i]/$t[$i+1]/ge;
}
print "mv $o $n\n";
`mv $o $n`;
for ($i = 0; $i < @t; $i+=2) {
print "perl -pi -w -e 's/$t[$i]/$t[$i+1]/ge;' $n\n";
`perl -pi -w -e 's/$t[$i]/$t[$i+1]/ge;' $n`;
}
}
}
exit (0);