modify.sh

File Name Modification - Oliver Hader, 2014-02-24 15:24

Download (1.33 KB)

 
1
#!/bin/bash
2

    
3
files=$(find . | grep DataSet | grep Record)
4

    
5
for file in $files;
6
do
7
	filename=$(basename $file)
8
	directory=$(dirname $file)
9
	basedirectory=$(dirname $directory)
10
	basedirectory=$(dirname $basedirectory)
11
	newname=$filename
12
#	newname=$(echo $newname | sed 's/createAndCopy/createCopied/g')
13
#	newname=$(echo $newname | sed 's/createAndLocalize/createLocalized/g')
14
	newname=$(echo $newname | sed 's/ParentContentRecordAndHotelChildRecord/ParentContentWithHotelChild/g')
15
	newname=$(echo $newname | sed 's/ParentContentRecordWithHotelAndOfferChildRecords/ParentContentWithHotelAndOfferChildren/g')
16
	newname=$(echo $newname | sed 's/AllModifiedRecords/All/g')
17
	newname=$(echo $newname | sed 's/ChildRecords/Children/g')
18
	newname=$(echo $newname | sed 's/Record//g')
19
	newname=$(echo $newname | sed 's/CategoryRelation/Relation/g')
20

    
21
	functionname=$(echo $filename | sed 's/\.csv$//')
22
	newfunctionname=$(echo $newname | sed 's/\.csv$//')
23
	testfile=$basedirectory/AbstractActionTestCase.php
24

    
25
	sed -i '' -e "s/function $functionname(/function $newfunctionname(/" $testfile
26

    
27
	newname=$(echo $newname | sed 's/And/N/g')
28
	newname=$(echo $newname | sed 's/With/N/g')
29
	newdatasetname=$(echo $newname | sed 's/\.csv$//')
30

    
31
	mv $file $directory/$newname
32

    
33
	sed -i '' -e "s/filename/$newname/" $testfile
34
	sed -i '' -e "s/'$functionname'/'$newdatasetname'/" $testfile
35

    
36
done