Scripte um Zuordnung von Etiketten erweitern?

Hallo,

gibt es die Möglichkeit, ein Script so zu erweitern, dass einer Datei direkt ein Etikett in Devonthink zugeordnet wird?
Ich benutze dieses Script zum Überwachen eines Ordners:

on adding folder items to this_folder after receiving added_items
	try
		if (count of added_items) is greater than 0 then
			tell application id "DNtp"
				launch
				set theGroup to get record with uuid "xxxxxxxxxxxxxxxxxxxxxxxxx"
			end tell
			repeat with theItem in added_items
				try
					set thePath to theItem as text
					if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
						tell application id "DNtp"
							set theRecord to import thePath to theGroup
							if exists theRecord then tell application "Finder" to delete theItem
						end tell
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to

… und diese zum Verarbeiten in Hazel:

tell application "Finder"
	set _path to (the POSIX path of theFile as string)
	set {_name, _extension} to {name, name extension} of theFile
	
	-- optional: hide extension in Finder
	set extension hidden of theFile to true
	
	-- optional: remove extension for DEVONthink displays
	set _name to text 1 thru -((count _extension) + 2) of _name
	set _extension to "." & _extension
end tell

-- Launch DEVONthink if it isn't already open.
tell application "System Events"
	if not (exists process "DEVONthink Pro Office") then
		tell application id "com.devon-technologies.thinkpro2" to activate
	end if
end tell

-- Import the file.

tell application id "com.devon-technologies.thinkpro2"
	set theGroup to get record with uuid "xxxxxxxxxxxxxxxxxxxxxxxxx"
	
	-- choose one option, Index or Import, comment out the other
	set theImport to import _path name _name to theGroup
	-- set theIndex to indicate _path to theGroup
end tell

Kann ich diese Scripte um die Zuordnung eines Etiketts erweitern? Leider habe ich von Scripts keine Ahnung, daher wäre ich für ein Beispiel sehr dankbar.
Grüße
doescher

Ersetzen Sie z.B. die Zeile…


if exists theRecord then tell application "Finder" to delete theItem

…durch folgende Code, um das 1. Etikett zu setzen:

if exists theRecord then 
	tell application "Finder" to delete theItem
	set label of theRecord to 1
end

In absehbarer Zeit werden sich solche Operationen auch ohne AppleScript & Hazel leicht automatisieren lassen.

Hallo,

das hat prima bei der Überwachung der Ordner durch Devonthink funktioniert, Danke!

Leider gibt es bei Hazel aber Fehler. Wo kann ich die Zeile in das Script einfügen (einfach »set label of theRecord to 1« nach der Zeile »set theGroup…« oder »set theImport…« einzufügen funktioniert nicht)?

-- Import the file.

tell application id "com.devon-technologies.thinkpro2"
   set theGroup to get record with uuid "xxxxxxxxxxxxxxxxxxxxxxxxx"
   
   -- choose one option, Index or Import, comment out the other
   set theImport to import _path name _name to theGroup
   -- set theIndex to indicate _path to theGroup
end tell

Da warte ich schon drauf. Bis dahin muss ich aber noch viele über Hazel machen (lassen), daher meine Frage.

Danke
doescher

Richtig, denn Sie verwenden “theRecord” nicht als Variable in der hier gezeigten Zeile. Sie verwenden “theImport” als Variable.

(Übersetzt mit deepl.com)

Super, jetzt funktioniert es. Danke!

Gern geschehen.