4 if [ "$(basename "$0")" == "dropbox_to_read" ]; then
6 LOCTMPDIR="$(mktemp -d)"
7 PDF_FILE=$(bibtex_to_paper --only-print "$a")
8 mkdir -p "$LOCTMPDIR/a"
9 mkdir -p "$LOCTMPDIR/b"
10 cp -l "$PDF_FILE" "$LOCTMPDIR/a/file.pdf";
11 if [ -e "${PDF_FILE}.annot" ]; then
12 cp "$PDF_FILE" "$LOCTMPDIR/b/file.pdf";
13 chmod u+w "$LOCTMPDIR/b/file.pdf"
14 qprint -d "${PDF_FILE}.annot" | patch -d "$LOCTMPDIR/b" --binary;
16 cp "$PDF_FILE" "$LOCTMPDIR/b/file.pdf";
17 chmod u+w "$LOCTMPDIR/b/file.pdf"
19 cp "$LOCTMPDIR/b/file.pdf" ~/Dropbox/research_papers/to_read/"$(basename "$PDF_FILE")";
20 rm -f "$LOCTMPDIR/a/file.pdf"
21 rm -f "$LOCTMPDIR/b/file.pdf"
22 rmdir "$LOCTMPDIR/a" "$LOCTMPDIR/b" "$LOCTMPDIR"
26 if [ "$(basename "$0")" == "dropbox_read" ]; then
27 #echo "Currently not implemented";
29 while IFS= read -r -d '' file; do
31 PDF_FILE="$(bibtex_to_paper --only-print --search-by-file "$(basename "$file")")"
32 if [ -n "$PDF_FILE" ]; then
34 LOCTMPDIR="$(mktemp -d)"
35 mkdir -p "$LOCTMPDIR/a";
36 mkdir -p "$LOCTMPDIR/b";
37 cp -l "${PDF_FILE}" "$LOCTMPDIR/a/file.pdf";
38 chmod u+w "$LOCTMPDIR/a/file.pdf"
39 cp -l "$file" "$LOCTMPDIR/b/file.pdf";
40 echo "${PDF_FILE}.annot";
42 diff -Nura a b ) | qprint --encode --binary > "${PDF_FILE}.annot"
43 # delete the annot file if it has size 0
44 if ! [ -s "${PDF_FILE}.annot" ]; then
45 rm -f "${PDF_FILE}.annot"
47 rm -f "$LOCTMPDIR/a/file.pdf"
48 rm -f "$LOCTMPDIR/b/file.pdf"
49 rmdir "$LOCTMPDIR/a" "$LOCTMPDIR/b" "$LOCTMPDIR"
50 mv "$file" ~/Dropbox/research_papers/annotations_recorded
53 done < <(find ~/Dropbox/research_papers/read/ -type f -print0)