-
Notifications
You must be signed in to change notification settings - Fork 1
/
unzip.sh
executable file
·61 lines (42 loc) · 1.07 KB
/
unzip.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
#! /usr/bin/env bash
set -e
#set -x
# TODO get last id from done-zips folder
# $ ls done-zips/ | tail -n1
# 000001759.the.trouble.with.harry.(1955).cze.1cd.(1759).zip
batch_2_size=100
batch_size=100
for i in $(seq $batch_2_size); do
start=1
echo
if [ -d done-zips ]; then
last_end=$(ls done-zips/ | sort | tail -n1 | cut -d. -f1 | sed -E 's/^0+//g')
elif [ -e last_end.txt ]; then
last_end=$(cat last_end.txt)
else
last_end=0 # first id is 1
fi
echo "last end: $last_end"
start=$((last_end + 1))
echo "start: $start"
echo "batch size: $batch_size"
end=$((start + batch_size))
echo "end: $end"
./extract.py -s $start -e $end -p zips
mkdir -p done-zips
mkdir -p unpacked-zips
while read -d$'\n' zipfile; do
printf .
#echo $zipfile
base="$(basename "$zipfile" .zip)"
if [ -d "unpacked-zips/$base" ]; then
rm -rf "unpacked-zips/$base"
fi
mkdir "unpacked-zips/$base"
# B: backup = rename duplicate files
unzip -B -q "$zipfile" -d "unpacked-zips/$base"
mv "$zipfile" done-zips/
#break
done < <(find zips -mindepth 1 -maxdepth 1 -name "*.zip")
echo $end >last_end.txt
done