Line 64... |
Line 64... |
64 |
[[ ! -d "$1" ]] && echo "Directory doesn't exist" && exit 1 |
64 |
[[ ! -d "$1" ]] && echo "Directory doesn't exist" && exit 1 |
65 |
cd $1 |
65 |
cd $1 |
66 |
|
66 |
|
67 |
# if there are no files with $EXT extension in the directory then quit |
67 |
# if there are no files with $EXT extension in the directory then quit |
68 |
ls -f *.$EXT > /dev/null 2>&1 |
68 |
ls -f *.$EXT > /dev/null 2>&1 |
69 |
[[ "$?" -ne 0 ]] && exit 1 |
69 |
if [ "$?" -eq 0 ]; then |
70 |
|
- |
|
71 |
for i in *.$EXT; do |
70 |
for i in *.$EXT; do |
72 |
echo "processing " $i |
71 |
echo "processing " $i |
73 |
PREFIX=`echo $i | cut -d $DELIM -f1,2` |
72 |
PREFIX=`echo $i | cut -d $DELIM -f1,2` |
74 |
OBSERVATORY=`echo $PREFIX | cut -d $DELIM -f2` |
73 |
OBSERVATORY=`echo $PREFIX | cut -d $DELIM -f2` |
75 |
POSTFIX=`echo $i | cut -d $DELIM -f4` |
74 |
POSTFIX=`echo $i | cut -d $DELIM -f4` |
76 |
|
75 |
|
77 |
TIMESTAMP=`echo "$i" | cut -d $DELIM -f3` |
76 |
TIMESTAMP=`echo "$i" | cut -d $DELIM -f3` |
78 |
YEAR=20`echo "$TIMESTAMP" | cut -c 1-2` |
77 |
YEAR=20`echo "$TIMESTAMP" | cut -c 1-2` |
79 |
MONTH=`echo "$TIMESTAMP" | cut -c 3-4` |
78 |
MONTH=`echo "$TIMESTAMP" | cut -c 3-4` |
80 |
DAY=`echo "$TIMESTAMP" | cut -c 5-6` |
79 |
DAY=`echo "$TIMESTAMP" | cut -c 5-6` |
81 |
HOUR=`echo "$POSTFIX" | cut -c 1-2` |
80 |
HOUR=`echo "$POSTFIX" | cut -c 1-2` |
82 |
|
81 |
|
83 |
# observatory / year / month / day / hour |
82 |
# observatory / year / month / day / hour |
84 |
DAYDIR="$OBSERVATORY$SLASH$YEAR$SLASH$MONTH$SLASH$DAY$SLASH$HOUR" |
83 |
DAYDIR="$OBSERVATORY$SLASH$YEAR$SLASH$MONTH$SLASH$DAY$SLASH$HOUR" |
85 |
|
84 |
|
86 |
# create directory with observatory name, year, month and day if hasn't existed before |
85 |
# create directory with observatory name, year, month and day if hasn't existed before |
87 |
[[ -d "$DAYDIR" ]] || mkdir -p "$DAYDIR" |
86 |
[[ -d "$DAYDIR" ]] || mkdir -p "$DAYDIR" |
- |
|
87 |
|
- |
|
88 |
mv "$i" "$DAYDIR" |
- |
|
89 |
done |
88 |
|
90 |
|
- |
|
91 |
echo -n "$OBSERVATORY$SLASH$YEAR$SLASH$MONTH$SLASH$DAY" > LAST |
- |
|
92 |
else |
- |
|
93 |
echo "No image files to sort" |
- |
|
94 |
fi |
- |
|
95 |
|
- |
|
96 |
DIR="bolids" |
- |
|
97 |
|
- |
|
98 |
ls -f *.wav > /dev/null 2>&1 |
- |
|
99 |
if [ "$?" -eq 0 ]; then |
- |
|
100 |
for i in bolid_*.wav; do |
- |
|
101 |
echo "processing bolid " $i |
- |
|
102 |
|
- |
|
103 |
PREFIX=`echo $i | cut -d $DELIM -f1,2` |
- |
|
104 |
OBSERVATORY=`echo $PREFIX | cut -d $DELIM -f2` |
- |
|
105 |
TIMESTAMP=`echo "$i" | cut -d $DELIM -f3` |
- |
|
106 |
YEAR=20`echo "$TIMESTAMP" | cut -c 1-2` |
- |
|
107 |
OUTDIR="$OBSERVATORY$SLASH$DIR$SLASH$YEAR" |
- |
|
108 |
|
- |
|
109 |
[[ -d "$OUTDIR" ]] || mkdir -p "$OUTDIR" |
89 |
mv "$i" "$DAYDIR" |
110 |
mv $i "$OUTDIR" |
- |
|
111 |
done |
90 |
done |
112 |
else |
- |
|
113 |
echo "No wav files to sort" |
- |
|
114 |
fi |
91 |
|
115 |
|
- |
|
116 |
ls -f *.aux > /dev/null 2>&1 |
- |
|
117 |
if [ "$?" -eq 0 ]; then |
- |
|
118 |
for i in bolid_*.aux; do |
- |
|
119 |
echo "processing bolid metadata " $i |
- |
|
120 |
|
- |
|
121 |
PREFIX=`echo $i | cut -d $DELIM -f1,2` |
- |
|
122 |
OBSERVATORY=`echo $PREFIX | cut -d $DELIM -f2` |
- |
|
123 |
TIMESTAMP=`echo "$i" | cut -d $DELIM -f3` |
- |
|
124 |
YEAR=20`echo "$TIMESTAMP" | cut -c 1-2` |
92 |
echo -n "$OBSERVATORY$SLASH$YEAR$SLASH$MONTH$SLASH$DAY" > LAST |
125 |
OUTDIR="$OBSERVATORY$SLASH$DIR$SLASH$YEAR" |
- |
|
126 |
|
- |
|
127 |
[[ -d "$OUTDIR" ]] || mkdir -p "$OUTDIR" |
- |
|
128 |
mv $i "$OUTDIR" |
- |
|
129 |
done |
- |
|
130 |
else |
- |
|
131 |
echo "No aux files to sort" |
- |
|
132 |
fi |
93 |
|
133 |
|
94 |
exit 0 |
134 |
exit 0 |
95 |
|
135 |
|
96 |
|
136 |
|
- |
|
137 |
|