- Registriert
- 21.06.15
- Beiträge
- 2
Hallo zusammen,
Ich möchte von PDF's die Spotlight Kommentare, die jeweils mit ";" getrennt werden (z.B. "Banane;Apfel;Kirsche") als Keywords in die PDF schreiben lassen. Die mit ";" getrennten Kommentare sollten dabei als einzelne Keywords verwendet werden, in meinem Fall würden beim obigen PDF-Kommentar "Banane;Apfel;Kirsche" drei Keywords entstehen.
Ich habe folgenden Code ausfindig gemacht und etwas abgeändert (Applescript mit Exiftool),: der Code liest die Kommentare von PDF's aus und speichert sie als Keyword in die PDF's, wobei die bereits vorhandenen Keywords nicht gelöscht werden. Der Code gibt jedoch den Kommentar als ein Keyword aus, d.h. ich weiss nicht, wie ich den Code abändern muss, damit die Kommentare, die mit ";" getrennt sind ("Banane;Apfel;Kirsche"), als einzelne Keywords - Keyword 1= Banane, Keyword 2 = Apfel, Keyword 3 = Kirsche - gespeichert werden.
Ich möchte von PDF's die Spotlight Kommentare, die jeweils mit ";" getrennt werden (z.B. "Banane;Apfel;Kirsche") als Keywords in die PDF schreiben lassen. Die mit ";" getrennten Kommentare sollten dabei als einzelne Keywords verwendet werden, in meinem Fall würden beim obigen PDF-Kommentar "Banane;Apfel;Kirsche" drei Keywords entstehen.
Ich habe folgenden Code ausfindig gemacht und etwas abgeändert (Applescript mit Exiftool),: der Code liest die Kommentare von PDF's aus und speichert sie als Keyword in die PDF's, wobei die bereits vorhandenen Keywords nicht gelöscht werden. Der Code gibt jedoch den Kommentar als ein Keyword aus, d.h. ich weiss nicht, wie ich den Code abändern muss, damit die Kommentare, die mit ";" getrennt sind ("Banane;Apfel;Kirsche"), als einzelne Keywords - Keyword 1= Banane, Keyword 2 = Apfel, Keyword 3 = Kirsche - gespeichert werden.
Code:
on run
open (choose file with multiple selections allowed)
end run
on open (dItems)
repeat with i in dItems
tell application "Finder" to set Thecomment to comment of i
set myPosixPath to quoted form of POSIX path of i
set oldkeywords to do shell script "exiftool -keywords " & myPosixPath
set {tid, AppleScript'stext item delimiters} to {AppleScript'stext item delimiters, ":"}
set Keywordstring to ""
try
set oldkeywords to text 2 thru -1 of text item 2 of oldkeywords
set AppleScript'stext item delimiters to ", "
set oldkeywords to text items of oldkeywords
repeat with i from 1 to count of oldkeywords
set theKEYWORD to quoted form of itemi of oldkeywords
if (count of theKEYWORD) < 66 then
set theKEYWORD to " -keywords=" & theKEYWORD
set Keywordstring to Keywordstring & theKEYWORD
else
display dialog "keyword zu lang: " & theKEYWORD giving up after 5
end if
end repeat
end try
try
set AppleScript'stext item delimiters to ", "
set newkeywords to text items of Thecomment
repeat with i from 1 to count of newkeywords
set theKEYWORD to quoted form of itemi of newkeywords
if (count of theKEYWORD) is not greater than 66 and (count of theKEYWORD) is not equal to 2 then
set theKEYWORD to " -keywords=" & theKEYWORD
set Keywordstring to Keywordstring & theKEYWORD
else
display dialog "Problem mit keyword: " & theKEYWORD giving up after 5
end if
end repeat
end try
set tid to AppleScript'stext item delimiters
do shell script "exiftool" & Keywordstring & " " & myPosixPath
end repeat
end open