Statistiques
| Branche: | Révision:

inraetemplate / rename_solution.sh @ fa2aa88f

Historique | Voir | Annoter | Télécharger (1,141 ko)

1
#!/bin/bash
2

    
3
newname=$2
4
oldname=$1
5

    
6
echo "rename project from ${oldname} to $newname"
7
#mv ${oldname} $newname
8
#cd ${newname}
9

    
10
echo "####################### remove cache & Debug #########################"
11
find . -type d -name '*.cache' -exec rm -fr {} \;
12
find . -iname '*.cache' -exec rm -f {} \;
13
find . -type d -name '*Debug' -exec rm -fr {} \;
14
find . -type d -name '*Release' -exec rm -fr {} \;
15

    
16

    
17
echo "####################### mv folders >3 pass for the depth #########################"
18
# mv folders >3 pass for the depth
19
for c in {1..5}
20
do
21
	for i in $(find . -type d -name '*'${oldname}'*')
22
	do
23
		n=$(echo $i|sed 's@\b'${oldname}'\b@'${newname}'@g')
24
		echo -en $i
25
		echo " ==> $n"
26
		mv -f $i $n
27
	done
28
done
29

    
30

    
31
echo "####################### rename files #########################"
32
for c in {1..2}
33
do
34
	for i in $(find . -type f -name '*'${oldname}'.*')
35
	do
36
		echo -en "$i"
37
		n=$(echo $i|sed 's/\b'${oldname}'\b/'${newname}'/g')
38
		echo " ==> $n"
39
		mv -f $i $n
40
	done
41
done
42

    
43
echo "####################### replace in file #########################"
44
for i in $(find . -type f)
45
do
46
	echo $i
47
	sed -i 's/'${oldname}'/'${newname}'/g' $i
48
done
49

    
50
cd ..
51
mv ${oldname} ${newname}
52
exit 0