-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathnewCopyData.sh
executable file
·48 lines (36 loc) · 1.27 KB
/
newCopyData.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
#!/bin/bash
# Copyright xmuspeech (Author:Snowdar 2018-7-25)
topdir=data
clean=true
force=false # for overwrite
. subtools/parse_options.sh
if [[ $# != 2 ]];then
echo "[exit] Num of parameters is not equal to 2"
echo "usage:$0 --force [false|true] <prefixes> <src-dirs>"
exit 1
fi
pre=$1
srcs=$2
for src in $srcs;do
[ ! -d "$src" ] && tmp=$src && src=$topdir/$src && [ ! -d "$src" ] && echo "[exit] No such dir $tmp or $src" && exit 1
name=`basename $src`
target=$topdir/${pre}/$name
[ "$src" == "$target" ] && echo "[Warning] data-dir $src is same to target-data-dir, so skip it" && continue
[ -d $target ] && [ "$force" == "false" ] && echo "[exit] $target is exist, please delete it carefully by yourself" && exit 1
rm -rf $target
mkdir -p $target
echo "Copy $src to $target..."
for x in wav.scp utt2spk spk2utt;do
[ ! -f $src/$x ] && echo "[exit] Expected $src/$x to exist at least." && exit 1
done
trials=""
for path in $(find $src -name "*trials");do
trials="$trials $(basename $path)"
done
extra=
[ "$clean" == "false" ] && extra="feats.scp vad.scp"
for x in wav.scp utt2spk spk2utt utt2num_frames utt2dur reco2dur text utt2gender spk2gender $extra $trials;do
[ -f $src/$x ] && cp $src/$x $target/ && echo "[ $x ] copy done"
done
echo "Copy done. Your new datadir is $target."
done