-
Notifications
You must be signed in to change notification settings - Fork 3
/
reflavour.sh
executable file
·68 lines (62 loc) · 1.8 KB
/
reflavour.sh
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
# Bash script for replacing the flavour Tag in the file name of a perambulator
# and its associated random vector
#!/bin/bash
# Perambulator Path
loc_peram=/hiskp2/perambulators/A40.24/strange_2464/
new_loc=/hiskp2/perambulators/A40.24/new/strange_2464/
# Replace flv_old in file name by flv_new in file name
flv_old="u"
flv_new="s"
# The script operates configuration-wise, need configs range
bgn=1286
end=1822
dst=4
# Number of perambulators per config
per_cfg=5
# Flag for storage layout (rnd_vec subfolders yes or no?)
rnd_vec=true
# go to perambulator location
cd $loc_peram
pwd
# loop over all configurations that need renaming
for ((c=$bgn; c<=$end; c+=$dst)); do
cfg=`printf %04d $c`
cd cnfg${cfg}
mkdir -p ${new_loc}/cnfg${c}
# Substructure present?
if [ "$rnd_vec" = true ]; then
# Yes
for (( r=0; r<$per_cfg; r+=1 )); do
cd rnd_vec_$r
mkdir -p $new_loc/cnfg$c/rnd_vec_$r
# Rename perambulator
per_old=$(ls perambulator*)
if [ -f $per_old ]; then
per_new=${per_old//.${flv_old}./.${flv_new}.}
cp $per_old $new_loc/cnfg$c/rnd_vec_$r/$per_new
# Rename randomvector
rnd_old=$(ls randomvector*)
rnd_new=${rnd_old//.${flv_old}./.${flv_new}.}
cp $rnd_old $new_loc/cnfg$c/rnd_vec_$r/$rnd_new
fi
cd ../
done
else
# No
for (( r=0; r<$per_cfg; r+=1 )); do
# Rename perambulator
per_old=$(ls perambulator.rndvecnb0${r}*)
if [ -f $per_old ]; then
per_new=${per_old//.${flv_old}./.${flv_new}.}
cp $per_old $per_new
# Rename randomvector
rnd_old=$(ls randomvector.rndvecnb0${r}*)
rnd_new=${rnd_old//.${flv_old}./.${flv_new}.}
cp $rnd_old $rnd_new
fi
done
fi
cd ../
done
nb_cfg=$(( ($end-$bgn)/$dst + 1 ))
echo "Renamed $nb_cfg configurations"