Oeffnen von Dateien per AppleScript

ricci007

Aktives Mitglied
Thread Starter
Dabei seit
11.10.2004
Beiträge
2.536
Reaktionspunkte
13
Hi,

ich habe noch was. Ich moechte alle Bilder in einem Ordner aufmachen und automatisch Auto-Tonwertkorrektur, Auto-Farbe und Auto-Kontrast durchfuehren lassen sowie die Bilder in 640x(automatisch) verkleinern. Aber bei mir scheitert es schon daran, eine Datei zu oeffnen:

Code:
property type_list_ : {"TIFF", "PNG", "JPG"}
property extension_list_ : {"tif", "tiff", "png", "jpg", "jpeg"}
property hdd_ : "Macintosh HD:"

on run
	tell application "Finder"
		set path_ to choose folder
		set files_ to every file of path_
		
		repeat with file_ in files_
			if the file type of file_ is in the type_list_ or name extension of file_ is in the extension_list_ then
				tell application "Adobe Photoshop CS3"
					activate # PS in den Vordergrund bringen
					
					#set display dialogs to never
					set jpgOptions to {class:JPEG save options, format options:optimized, quality:10}
					#set ruler units of settings to pixel units
					
					open file ((hdd_ & file_) as file) showing dialogs never
					#save this_image in dest_folder as JPEG
				end tell
			end if
		end repeat
	end tell
end run

Wenn ich den oberen Code zur Ausfuehrung bringt kommt: "Macintosh HD:user:Test:test.jpg kann nicht in den Typ file umgewandelt werden!"

Weisz jemand, warum?

LG,

ricci007
 
Hab's selber hinbekommen:

Code:
property type_list_ : {"JPG"}
property extension_list_ : {"jpg", "jpeg"}
property hdd_ : "Macintosh HD:"

on run
	tell application "Finder"
		set path_ to choose folder
		set files_ to every file of path_
		
		repeat with file_ in files_
			set aliasFile_ to file_ as alias
			
			# fuer die entsprechenden Dateien
			if the file type of file_ is in the type_list_ or name extension of file_ is in the extension_list_ then
				# Auto-Tonwertkorrektur, Auto-Farbe, Auto-Kontrast
				tell application "Adobe Photoshop CS3"
					activate # PS in den Vordergrund bringen
					set jpgOptions to {class:JPEG save options, format options:optimized, quality:10}
					set thisFile_ to open aliasFile_
					
					# Photoshop per Shortcuts steuern
					tell application "System Events" -- das Programm System Events wird aufgerufen
						keystroke "i" using {option down, command down} # Groesze der aktuellen Datei aendern
						keystroke "640" # in der Breite sollen es 640px sein (Vorsicht: Voreinstellungen!!!)
						keystroke return # mit ENTER bestaetigen
						
						keystroke "l" using {shift down, command down} # SHIFT+APPLE+L == Auto-Tonwertkorrektur
						keystroke "l" using {option down, shift down, command down} # ALT+SHIFT+APPLE+L == Auto-Kontrast
						keystroke "b" using {shift down, command down} # SHIFT+APPLE+B == Auto-Farbe
						keystroke "s" using command down # aktuelle Datei speichern
						keystroke return # ENTER druecken (Vorsicht: Voreinstellung Qualitaet!!!)
						keystroke "w" using command down # aktuelle Datei schlieszen
					end tell
				end tell
			end if
			
			say "yes" # ein Bild wurde konvertiert
		end repeat
		
		tell application "Adobe Photoshop CS3" to quit # PS am Ende des Workflows schlieszen
	end tell
end run
 
Zurück
Oben Unten