This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
parse.sh
executable file
·81 lines (72 loc) · 1.47 KB
/
parse.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
73
74
75
76
77
78
79
80
81
#!/bin/sh
# parse.sh is a shell script for creating the input file in necessary
# format for the programs included in EmoDetect. This shell script
# recursively goes through all subdirectories, and lists all .jpg files
# along with a label to indicate the associated emotion. This file has been
# optimised to work with the MUG facial expressions data set mentioned in
# the README. This file may need to be changed if another data set is used.
#
# Shell script to find out all the files under a directory and its
# subdirectories. This also takes into consideration those files or
# directories which have spaces or newlines in their names
DIR="."
category=-1
list_files()
{
if !(test -d "$1")
then echo $1; return;
fi
cd "$1"
#echo; echo `pwd`:; #Display Directory name
for i in *
do
if test -d "$i" #if dictionary
then
case $i in
"anger")
category=0;
;;
"disgust")
category=1;
;;
"fear")
category=2;
;;
"happiness")
category=3;
;;
"neutral")
category=4;
;;
"sadness")
category=5;
;;
"surprise")
category=6;
;;
"")
;;
*)
esac
list_files "$i" #recursively list files
cd ..
else
case $i in
*jpg*)
echo "$category\t"`pwd`\/"$i";
;;
esac
fi
done
}
if [ $# -eq 0 ]
then
list_files .
exit 0
fi
for i in $*
do
DIR="$1"
list_files "$DIR"
shift 1 #To read next directory/file name
done