Problem mit einem Script in Automator

S

schau.hans

Aktives Mitglied
Thread Starter
Dabei seit
09.01.2006
Beiträge
511
Reaktionspunkte
21
Hallo Zusammen,

hab mal vor einiger Zeit im Internet ein AppleScript gefunden das alle im Finder ausgewählten Pages Files öffnet und als PDF an einem bestimmten Ort speichert. Funktioniert auch soweit.
Ich will aber das jedes PDF File im selben Ordner wie das Original gespeichert wird.

Im Automator werden die ausgewählten Finder Objekte abgefragt und mit Filtern alle Pages-Files gefiltert und an das Script übergeben.


Hier der Code vom Script:
Bei "set target_folder to (path to this_doc) as text" muss was ein Fehler sein da es nicht funktionieren will.
Code:
on run {input, parameters}
	if input is not {} then
		# save as PDF in output folder
		tell application "Pages"
			set document_count to 0
			set result_list to {}
			repeat with doc in input
				try
					set this_doc to open doc
					set doc_name to this_doc's name
					set target_folder to (path to this_doc) as text
					set pdf_doc to (((target_folder) as text) & doc_name & ".pdf")
					save this_doc in pdf_doc
					close this_doc
					copy pdf_doc as alias to the end of result_list
					set document_count to document_count + 1
				end try
			end repeat
		end tell
	end if
	return result_list
end run
 
path to gibt den Dateipfad an, nicht den Pfad zum Ordner, in dem sich die Datei befindet. Was du brauchst ist

tell app "Finder" to set target_folder to container of this_doc

Vorausgesetzt this_doc ist vom Typ alias/file/folder
 
  • Gefällt mir
Reaktionen: schau.hans
Danke jetzt hat's funktioniert.
 
Zurück
Oben Unten