-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrename.sh
More file actions
executable file
·72 lines (49 loc) · 1.59 KB
/
rename.sh
File metadata and controls
executable file
·72 lines (49 loc) · 1.59 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -x
orig_modname=new_script
dest_modname=foo
orig_scriptname=script
dest_scriptname=bar
# Call sed to fix the module name inside the files:
read -d '' files <<EOF
./README.md
./setup.py
./Makefile.in
./bin/$orig_scriptname
./bin/$orig_modname/__init__.py
./bin/$orig_modname/boilerplate.py
./bin/$orig_modname/conf.py
./bin/$orig_modname/date_file_handler.py
./bin/$orig_modname/test/__init__.py
./bin/$orig_modname/test/test_boilerplate.py
./etc/$orig_modname/${orig_scriptname}_logging.conf
EOF
for f in $files ; do
# Linux:
#sed -i -e "s/$orig_modname/$dest_modname/g" $f || exit $?
# OS X:
sed -i '' -e "s/$orig_modname/$dest_modname/g" $f || exit $?
done
# Rename the appropriate directories according to the new module name.
read -d '' dirs <<EOF
./bin/$orig_modname
./etc/$orig_modname
./share/$orig_modname
EOF
for d in $dirs ; do
mv $d $(dirname $d)/$dest_modname || exit $?
done
# Call sed and rename files according to the new script name.
# Linux:
#sed -i -e "s/${orig_scriptname}_logging/${dest_scriptname}_logging/g" \
# ./bin/$orig_scriptname || exit $?
#sed -i -e "s/${orig_scriptname}_logging/${dest_scriptname}_logging/g" \
# setup.py || exit $?
# OS X:
sed -i='' -e "s/${orig_scriptname}_logging/${dest_scriptname}_logging/g" \
./bin/$orig_scriptname || exit $?
sed -i='' -e "s/${orig_scriptname}_logging/${dest_scriptname}_logging/g" \
setup.py || exit $?
mv ./bin/$orig_scriptname ./bin/$dest_scriptname || exit $?
mv ./etc/$dest_modname/${orig_scriptname}_logging.conf \
./etc/$dest_modname/${dest_scriptname}_logging.conf || exit $?