Automation für Pages Dokumente in PDF

Yes, that looks very good. I think that works now too.

If I notice anything else, I’ll let you know :smiley:

Was ist denn der praktische Unterschied zwischen selected records und selection? (Ich erlaube mir mal wieder auf Deutsch zu schreiben). Oder geht es in dieser Änderung nur darum, den aktuellen Wert der Auswahl zwischenzuspeichern, sodass set theSelection to selected records ebenso funktionieren würde?

Der wesentliche Unterschied der Änderung ist v.a., dass die Auswahl zwischengespeichert wird, da sie sich ändern kann durch das Skript.

Danke. selection bzw. selected records ist also sozusagen eine “live reference”. Das wäre vielleicht eine Erwähnung in der Dokumentation wert?

Das trifft eigentlich auf jede Eigenschaft zu, dass sie sich durch Skripte ändern kann, sofern sie nicht in Variablen gespeichert wird.

Magst du bitte noch das funktionierende Skript in seiner Vollständigkeit hier posten? Das hilft anderen vielleicht :slight_smile:

Wenn du ein Skript postest, dann bitte eingebettet in ``` (jeweils auf einer eigenen Zeile vor und nach deinem Skript). Dann wird das Skript im Forum sauber gerendert.

Danke :slight_smile:

Sorry für die Verspätung, hätte ich beinahe vergessen. Na klar, hier das funktionsfähige komplette Script:

-- Convert Pages documents to PDF

property extensionList : {"pages"}

tell application id "DNtp"
	set theFolder to path to desktop folder as string --Schreibtisch als Pfad für die Konvertierung
	set theSelection to the selection
	repeat with theRecord in theSelection
		set thePath to (path of theRecord) as POSIX file
		set theFile to thePath as alias
		set theName to filename of theRecord --Dateiname aus DevonThink
		tell application "Finder"
			set ext to name extension of theFile
			if ext is in extensionList then
				set theFilename to characters 1 through ((length of theName) - (length of ext) - 1) of theName as string
				set theFilename to theFilename & ".pdf"
				set theConvertedPath to (theFolder & theFilename as string)
				tell application "Pages"
					set theDoc to open theFile
					export theDoc as PDF to file theConvertedPath
					close theDoc
				end tell
				tell application id "DNtp" to import POSIX path of theConvertedPath to (parent 1 of theRecord)
				if exists theConvertedPath then tell application "Finder" to delete theConvertedPath --löschen des konvertierten Files vom Schreibtisch
			end if
		end tell
	end repeat
end tell

Viel Spaß :wink:

2 Likes