-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamplegenerator.sh
More file actions
executable file
·56 lines (51 loc) · 1.21 KB
/
examplegenerator.sh
File metadata and controls
executable file
·56 lines (51 loc) · 1.21 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
#!/bin/bash
# ./examplegenerator.sh /home/friker/tmp/www/examples/rankfinder "fc" /home/friker/Systems/irankfinder/src/loopkiller/examples > ./config/pyRankFinder/examples.cfg
function printFile(){
urlb=$1
base=$2
path=$3
extension="${path##*.}"
filename=`basename $path`
cp $path $base"/"$filename
echo '<file name="'$filename'" url="'$urlb'/'$filename'" />'
}
function printFolder(){
urlb=$1
base=$2
path=$3
folder=`basename $path`
mkdir $base"/"$folder
echo '<folder name="'$folder'">'
}
function processPath(){
urlb=$1
base=$2
exts=$3
path=$4
if [[ -d $path ]]; then
# echo "$path is a directory"
folder=`basename $path`
printFolder $urlb $base $path
for f in $path/*; do
(processPath $urlb/$folder $base/$folder $exts $f)
done
echo "</folder>"
elif [[ -f $path ]]; then
#echo "$path is a file"
extension="${path##*.}"
filename="${path%.*}"
if [[ " ${exts[@]} " =~ " ${extension} " ]]; then
(printFile $urlb $base $path)
fi
#else
# echo "$path is not valid"
fi
}
URLB="http://localhost/tmp/examples/rankfinder"
BASE=$1
EXTS=$2
DIR=$3
mkdir -p $BASE
echo "<exset id='pyset'>"
processPath $URLB $BASE $EXTS $DIR
echo "</exset>"