-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdt_classify.sh
More file actions
executable file
·71 lines (51 loc) · 1.19 KB
/
Copy pathdt_classify.sh
File metadata and controls
executable file
·71 lines (51 loc) · 1.19 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
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
62
63
64
65
66
67
68
#!/bin/sh
# dt_classify : Output classification proposals for a DT record based on
# its database ID.
# Copyright (c) 2006, Eric Fedel. Released under the BSD License.
# (http://home.earthlink.net/~efedel/code/devon_think/index.html)
HELP_STR="Usage: $0 record_id"
while getopts \? opt
do
case "$opt"
in
\?) echo "$HELP_STR"; exit 1;;
esac
done
if [ $((OPTIND)) -gt $# ]
then
echo "ERROR: record_id argument is mandatory"
exit 2
fi
# Get Params
shift $((OPTIND - 1))
REC_ID=$1
# Input validation
echo $REC_ID | grep '[^0-9]'
if [ $? -eq 0 ]
then
echo "ERROR: record_id must be an integer"
exit 3
fi
# Applescript for classify
VAR=`osascript <<EOF
on record_info(r_id)
set nl to "\\\\\\\\n" -- newline (escaped)
tell application "DEVONthink Pro"
set r to get record with r_id
-- check that record exists
try
get r
on error msg
return "ERROR: Unable to find " & e_id as text & ": " & msg & nl
end try
-- output classification groups
set out to ""
repeat with g in classify record r
set out to out & location of g & name of g & nl
end repeat
end tell
return out
end
set result to record_info($REC_ID)
EOF`
echo -ne $VAR