-
Notifications
You must be signed in to change notification settings - Fork 0
/
scanner.sh
49 lines (43 loc) · 1.43 KB
/
scanner.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
date=$(date +%Y-%m-%d_%H:%M:%S)
echo =======SCAN START=======
echo 开始处理...
echo
# 建立目录 Create output file
mkdir -p output/$date
touch output/$date/.all.txt
# 扫描流程 Scanner working
# 处理png Process "png" file
if [ "$(ls input/*.png 2> /dev/null | wc -l)" != "0" ];then # 判断文件是否存在 IF "png" file exist
for i in input/*.png
do
result=$(zbarimg --raw -q ${i%%.*}.png) # 扫描 Scanning
echo $result>>output/$date/.all.txt # 保存到总文件 Save to total file
touch output/$date/${i#*/}.txt # 创建单文件 Create single file
echo $result>>output/$date/${i#*/}.txt # 保存到单文件 Save to single file
done
fi
# 处理jpg/jpeg Process "jpg/jpeg" file
if [ "$(ls input/*.jpg 2> /dev/null | wc -l)" != "0" ];then
for i in input/*.jpg
do
result=$(zbarimg --raw -q ${i%%.*}.png)
echo $result>>output/$date/.all.txt
touch output/$date/${i#*/}.txt
echo $result>>output/$date/${i#*/}.txt
done
fi
if [ "$(ls input/*.jpeg 2> /dev/null | wc -l)" != "0" ];then
for i in input/*.jpeg
do
result=$(zbarimg --raw -q ${i%%.*}.png)
echo $result>>output/$date/.all.txt
touch output/$date/${i#*/}.txt
echo $result>>output/$date/${i#*/}.txt
done
fi
# 完成 Finish!
echo ========SCAN END========
echo 处理完成,已将内容保存至 output/$date 文件夹.
echo 所有结果已保存至 output/$date/.all.txt 文件.
echo 20s后自动退出,您可以手动关闭窗口.
sleep 20