forked from Ptujec/LaunchBar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilm Suche.applescript
58 lines (49 loc) · 1.89 KB
/
Film Suche.applescript
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
-- http://forums.obdev.at/viewtopic.php?p=12250#p12250
-- additional coding by @ptujec and most of all :kelko:
on handle_string(thequery)
try
-- tell application "LaunchBar" to hide
set displayQueryString to ""
set commentQueryString to ""
set tagQueryString to ""
set firstLoop to true
repeat with aWord in every word in thequery
if not firstLoop then
set displayQueryString to displayQueryString & " && "
set commentQueryString to commentQueryString & " && "
set tagQueryString to tagQueryString & " && "
else
set firstLoop to false
end if
set displayQueryString to displayQueryString & " kMDItemDisplayName == " & quote & aWord & "*" & quote & "wc " & " && (kMDItemKind == \"*Film*\" || kMDItemKind == \"*Video*\")"
set commentQueryString to commentQueryString & "kMDItemFinderComment == " & quote & aWord & "*" & quote & "wc " & " && (kMDItemKind == \"*Film*\" || kMDItemKind == \"*Video*\")"
set tagQueryString to tagQueryString & "kMDItemOMUserTags == " & quote & aWord & "*" & quote & "wc " & " && (kMDItemKind == \"*Film*\" || kMDItemKind == \"*Video*\")"
end repeat
set endQueryString to "'(" & displayQueryString & ") || (" & commentQueryString & ") || ( " & tagQueryString & " )'"
set thecmd to "mdfind " & endQueryString
set theresult to do shell script thecmd
set thelist to {}
set allparas to every paragraph in theresult
repeat with apara in allparas
set end of thelist to (POSIX file apara) as alias
end repeat
if thelist is {} then
tell application "LaunchBar"
display in large type "Nix gefunden!" with sound "Submarine"
delay 0.7
hide
end tell
else
tell application "LaunchBar"
set selection to thelist
activate
end tell
end if
on error e
tell application "LaunchBar"
display in large type e with sound "Submarine"
delay 1.5
hide
end tell
end try
end handle_string