-
Notifications
You must be signed in to change notification settings - Fork 1
/
epic_extract_flow.sh
executable file
·72 lines (60 loc) · 1.97 KB
/
epic_extract_flow.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
69
70
71
72
#!/bin/bash
if [[ $# -lt 4 ]]
then
echo "Usage: $0 [EPIC-55 dir] [EPIC-100 extensions dir] [output_dir] [md5.csv]"
echo "Find tar file from either of the two directory structures, and extract them in one location."
echo "Download md5.csv from https://raw.githubusercontent.com/epic-kitchens/epic-kitchens-download-scripts/master/data/md5.csv"
exit 1
fi
epic55_dir="$1"
epic100_dir="$2"
output_dir="$3"
md5_csv="$4"
epic55_flow_tars=$(cat "$md5_csv" | grep /flow/ | awk -F, '{print $2}' | sort)
epic100_flow_tars=$(cat "$md5_csv" | grep /flow_frames/ | awk -F, '{print $2}' | sort)
num_errors=0
error_videos=""
while read tarfile
do
participant=$(echo "$tarfile" | awk -F/ '{print $4}')
videoid=$(echo "$tarfile" | awk -F/ '{print $5}' | awk -F. '{print $1}')
extract_dir="$output_dir/$participant/$videoid"
echo "Extracting $epic55_dir/$tarfile to $extract_dir"
mkdir -p "$extract_dir"
if tar xf "$epic55_dir/$tarfile" -C "$extract_dir"
then
true
else
printf '\xF0\x9F\x98\xAD' # loudly crying face
echo " ERROR OCCURED WHILE EXTRACTING TAR"
(( num_errors += 1 ))
error_videos="$error_videos$tarfile\n"
fi
done <<< "$epic55_flow_tars"
while read tarfile
do
participant=$(echo "$tarfile" | awk -F/ '{print $1}')
videoid=$(echo "$tarfile" | awk -F/ '{print $3}' | awk -F. '{print $1}')
extract_dir="$output_dir/$participant/$videoid"
echo "Extracting $epic100_dir/$tarfile to $extract_dir"
mkdir -p "$extract_dir"
if tar xf "$epic100_dir/$tarfile" -C "$extract_dir"
then
true
else
printf '\xF0\x9F\x98\xAD' # loudly crying face
echo " ERROR OCCURED WHILE EXTRACTING TAR"
(( num_errors += 1 ))
error_videos="$error_videos$tarfile\n"
fi
done <<< "$epic100_flow_tars"
if [ $num_errors -gt 0 ]
then
printf '\xF0\x9F\x98\xA1' # pouting face
echo " $num_errors errors occurred whilst extracting tar files."
echo "Failed list:"
printf "$error_videos"
else
printf '\xF0\x9F\x98\x8D' # smiling face with heart-shaped eyes
echo " All tar files successfully extracted"
fi