Schleife / InDesign JPG export?

M

Martin111

Registriert
Thread Starter
Dabei seit
03.02.2015
Beiträge
2
Reaktionspunkte
0
Hallo allerseits,

Ich habe untenstehendes Script (im Automator).
Es funktioniert einwandfrei. Bei einem geöffneten InDesign Dokument werden alle Seiten als JPG + PNG exportiert, dann wird das aktive Dokument geschlossen.
Aber es funktioniert leider nicht, wenn ich zum Beispiel 50 InDesign Dokumente geöffnet habe.....
Wie kann man eine Schleife einbauen, welche prüft, ob ein Dokument offen ist und die Aktion ständig wiederholt?

Wo im Script muss ich was abändern? Ich bin für jeden Tipp dankbar. Gruss Martin111




on run {input, parameters}

-- developed by macgrunt for use with InDesign
-- last updated April 2014
-- macgrunt.com


-- export jpgs and pngs from active InDesign document


tell application id "com.adobe.InDesign"
set mgFolder to file path of active document
set mgDocName to name of active document
end tell


----------------------------------
-- this bit shortens filename to first space
set text item delimiters of AppleScript to {" "}
set mgDocName to text item 1 of mgDocName
set text item delimiters of AppleScript to ""
----------------------------------


----------------------------------
-- this bit creates subfolders in the same location as the InDesign file
tell application "Finder"
if (exists folder "JPGs" of folder mgFolder) is false then
set mgJPGfolder to make new folder at mgFolder with properties {name:"JPGs"}
else
set mgJPGfolder to (mgFolder & "JPGs") as string
end if
set mgJPGfolder to mgJPGfolder as alias
if (exists folder "PNGs" of folder mgFolder) is false then
set mgPNGFolder to make new folder at mgFolder with properties {name:"PNGs"}
else
set mgPNGFolder to (mgFolder & "PNGs") as string
end if
set mgPNGFolder to mgPNGFolder as alias
end tell




tell application id "com.adobe.InDesign"
----------------------------------
-- here is where we set the export parameters
set Exporting Spread of JPEG export preferences to false
set JPEG export range of JPEG export preferences to export range
set JPEG Quality of JPEG export preferences to maximum
set jpeg color space of JPEG export preferences to RGB
set export resolution of JPEG export preferences to 72

set Exporting Spread of PNG export preferences to false
set PNG export range of PNG export preferences to export range
set PNG Quality of PNG export preferences to maximum
set PNG color space of PNG export preferences to RGB
set export resolution of PNG export preferences to 72
----------------------------------

repeat with mgCount from 1 to (count pages of active document)
set mgCount to mgCount as string
set Page String of JPEG export preferences to mgCount
set Page String of PNG export preferences to mgCount
set mgJpgFilePath to (mgJPGfolder & mgDocName & "_" & mgCount & ".jpg") as string
set mgPNGFilePath to (mgPNGFolder & mgDocName & "_" & mgCount & ".png") as string
tell active document
export format JPG to mgJpgFilePath without showing options
export format PNG format to mgPNGFilePath without showing options
end tell
end repeat

close active document
end tell

return input
end run
 
Hallo und willkommen hier im Forum!

Ich habe das Skript mal abgeändert:

Code:
[FONT=Verdana][B]on[/B] [/FONT][FONT=Verdana][B]run[/B][/FONT][FONT=Verdana] {[/FONT][FONT=Verdana]input[/FONT][FONT=Verdana], [/FONT][FONT=Verdana]parameters[/FONT][FONT=Verdana]}
[/FONT][FONT=Verdana]    [/FONT]
[COLOR=#5E6161][FONT=Verdana]    -- developed by macgrunt for use with InDesign[/FONT][/COLOR]
[COLOR=#5E6161][FONT=Verdana]    -- last updated April 2014[/FONT][/COLOR]
[COLOR=#5E6161][FONT=Verdana]    -- macgrunt.com[/FONT][/COLOR]
[FONT=Verdana]    [/FONT]
[FONT=Verdana]    [B]tell[/B] [I]application[/I] [I]id[/I] "com.adobe.InDesign"[/FONT]
[COLOR=#4F8F00][FONT=Verdana]        [COLOR=#000000][B]set[/B] allDocuments [B]to[/B] [I]documents[/I][/COLOR][/FONT][/COLOR]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]        [B]repeat[/B] [B]with[/B] aDocument [B]in[/B] allDocuments[/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] active document [B]to[/B] aDocument[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            -- export jpgs and pngs from active InDesign document[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] mgFolder [B]to[/B] file path [B]of[/B] active document[/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] mgDocName [B]to[/B] name [B]of[/B] active document[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            ----------------------------------[/COLOR][/FONT][/COLOR]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            -- this bit shortens filename to first space[/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] text item delimiters [B]of[/B] AppleScript [B]to[/B] {" "}[/COLOR][/FONT][/COLOR]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]            [B]set[/B] mgDocName [B]to[/B] [I]text item[/I] 1 [B]of[/B] mgDocName[/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] text item delimiters [B]of[/B] AppleScript [B]to[/B] ""[/COLOR][/FONT][/COLOR]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            ----------------------------------[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            ----------------------------------[/COLOR][/FONT][/COLOR]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            -- this bit creates subfolders in the same location as the InDesign file[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [B]tell[/B] [I]application[/I] "Finder"[/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]                [B]if[/B] ([B]exists[/B] [I]folder[/I] "JPGs" [B]of[/B] [I]folder[/I] mgFolder) [B]is[/B] [I]false[/I] [B]then[/B][/COLOR][/FONT]
[COLOR=#0433FF][FONT=Verdana][COLOR=#000000]                    [B]set[/B] mgJPGfolder [B]to[/B] [B]make[/B] new [I]folder[/I] at mgFolder with properties {name:"JPGs"}[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]                [B]else[/B][/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]                    [B]set[/B] mgJPGfolder [B]to[/B] (mgFolder & "JPGs") [B]as[/B] [I]string[/I][/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]                [B]end[/B] [B]if[/B][/COLOR][/FONT]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]                [B]set[/B] mgJPGfolder [B]to[/B] mgJPGfolder [B]as[/B] [I]alias[/I][/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]                [B]if[/B] ([B]exists[/B] [I]folder[/I] "PNGs" [B]of[/B] [I]folder[/I] mgFolder) [B]is[/B] [I]false[/I] [B]then[/B][/COLOR][/FONT]
[COLOR=#0433FF][FONT=Verdana][COLOR=#000000]                    [B]set[/B] mgPNGFolder [B]to[/B] [B]make[/B] new [I]folder[/I] at mgFolder with properties {name:"PNGs"}[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]                [B]else[/B][/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]                    [B]set[/B] mgPNGFolder [B]to[/B] (mgFolder & "PNGs") [B]as[/B] [I]string[/I][/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]                [B]end[/B] [B]if[/B][/COLOR][/FONT]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]                [B]set[/B] mgPNGFolder [B]to[/B] mgPNGFolder [B]as[/B] [I]alias[/I][/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [B]end[/B] [B]tell[/B][/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            ----------------------------------[/COLOR][/FONT][/COLOR]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            -- here is where we set the export parameters[/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] Exporting Spread [B]of[/B] JPEG export preferences [B]to[/B] [I]false[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] JPEG export range [B]of[/B] JPEG export preferences [B]to[/B] [I]export range[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] JPEG Quality [B]of[/B] JPEG export preferences [B]to[/B] [I]maximum[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] jpeg color space [B]of[/B] JPEG export preferences [B]to[/B] [I]RGB[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] export resolution [B]of[/B] JPEG export preferences [B]to[/B] 72[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] Exporting Spread [B]of[/B] PNG export preferences [B]to[/B] [I]false[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] PNG export range [B]of[/B] PNG export preferences [B]to[/B] [I]export range[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] PNG Quality [B]of[/B] PNG export preferences [B]to[/B] [I]maximum[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] PNG color space [B]of[/B] PNG export preferences [B]to[/B] [I]RGB[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]set[/B] export resolution [B]of[/B] PNG export preferences [B]to[/B] 72[/COLOR][/FONT][/COLOR]
[COLOR=#5E6161][FONT=Verdana][COLOR=#000000]            ----------------------------------[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [B]repeat[/B] [B]with[/B] mgCount [B]from[/B] 1 [B]to[/B] ([B]count[/B] [I]pages[/I] [B]of[/B] active document)[/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]                [B]set[/B] mgCount [B]to[/B] mgCount [B]as[/B] [I]string[/I][/COLOR][/FONT]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]                [B]set[/B] Page String [B]of[/B] JPEG export preferences [B]to[/B] mgCount[/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]                [B]set[/B] Page String [B]of[/B] PNG export preferences [B]to[/B] mgCount[/COLOR][/FONT][/COLOR]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]                [B]set[/B] mgJpgFilePath [B]to[/B] (mgJPGfolder & mgDocName & "_" & mgCount & ".jpg") [B]as[/B] [I]string[/I][/COLOR][/FONT][/COLOR]
[COLOR=#4F8F00][FONT=Verdana][COLOR=#000000]                [B]set[/B] mgPNGFilePath [B]to[/B] (mgPNGFolder & mgDocName & "_" & mgCount & ".png") [B]as[/B] [I]string[/I][/COLOR][/FONT][/COLOR]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]                [B]tell[/B] active document[/COLOR][/FONT][/COLOR]
[COLOR=#0433FF][FONT=Verdana][COLOR=#000000]                    [B]export[/B] format [I]JPG[/I] to mgJpgFilePath [B]without[/B] showing options[/COLOR][/FONT][/COLOR]
[COLOR=#0433FF][FONT=Verdana][COLOR=#000000]                    [B]export[/B] format [I]PNG format[/I] to mgPNGFilePath [B]without[/B] showing options[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]                [B]end[/B] [B]tell[/B][/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [B]end[/B] [B]repeat[/B][/COLOR][/FONT]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[COLOR=#812FDC][FONT=Verdana][COLOR=#000000]            [B]close[/B] active document[/COLOR][/FONT][/COLOR]
[FONT=Verdana][COLOR=#000000]            [/COLOR][/FONT]
[FONT=Verdana]        [B]end[/B] [B]repeat[/B][/FONT]
[FONT=Verdana]    [B]end[/B] [B]tell[/B][/FONT]
[FONT=Verdana]    [B]return[/B] input[/FONT]
[B]end [/B][FONT=Verdana][B]run[/B][/FONT]
 
Vielen Dank, du hast mir sehr geholfen! Martin
 
Zurück
Oben Unten