forked from nurtext/datev_extract
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper.sh
More file actions
executable file
·36 lines (31 loc) · 1.01 KB
/
wrapper.sh
File metadata and controls
executable file
·36 lines (31 loc) · 1.01 KB
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
#!/bin/bash
# Where to move extracted pdf if they don't already exist ?
PDF_DIR=".."
# I'm using summon with gopass provider https://github.com/gopasspw/gopass-summon-provider
# and have a secrets.yml with this content:
# ---
# DATEV_USERNAME: !var path/to/datev/entry:USERNAME
# DATEV_PASSWORD: !var path/to/datev/entry::PASSWORD
#
# alternatively, you can also set only your username with:
#DATEV_USERNAME=johndoe
#summon nodejs datev.js
for src in download/*pdf ;do
dest="$PDF_DIR/$(basename "${src}")"
if test -f "$dest";then
size_diff=$(( $(stat -c %s "$dest") - $(stat -c %s "$src") ))
if [ $size_diff -ne 0 ];then
echo "Size differ from $size_diff bytes between $src and $dest."
read -p "[S]kip/[o]verwrite dest/[d]elete src ?" ANS
case $ANS in
o*|O*) mv -vf "${src}" "$PDF_DIR/" ;;
d*|D*) rm -vf "${src}" ;;
esac
else
echo "File already exist with the size: ${src}"
rm -v "${src}"
fi
else
mv -v "${src}" "$PDF_DIR/"
fi
done