Automatische Platzierung von ausgewählten Word-, PDF- und InDesign-Dateien

von Martin Fischer am 22.01.09 0:21 in Daten importieren

placeSelectedFiles.as

In InDesign-Dok's platzieren wie automatischer Textfluss in CS3 wurde eine Möglichkeit angefragt, InDesing CS3 Dokumente automatisch zu platzieren.

Das folgende AppleScript platziert ausgewählte Word-Dateien (alle Dateien mit automatischen Textfluß), PDF-Dateien (alle Seiten) und CS3-Dateien (alle Seiten).


Das Skript ist eine Baustelle und könnte gelegentlich auch für andere Formate ausgebaut werden.



Skript ist lauffähig in:
InDesign Version CS3


-- placeSelectedFiles.as
--
tell application "Adobe InDesign CS3"
set myDoc to active document
set myunsortedFiles to choose file with multiple selections allowed
set user interaction level of script preferences to never interact
tell myDoc
set myFiles to my sort(myunsortedFiles)
repeat with myCounter from 1 to length of myFiles
set oneFile to item myCounter of myFiles
tell application "Finder"
set x to file (item myCounter of myFiles)
set myExt to name extension of file oneFile
set myFileType to file type of file oneFile
end tell
set myLastPage to last page of myDoc
if (count of page item of myLastPage) > 0 then
set myLastPage to make page
end if
if myFileType is "PDF " or myExt is "PDF" then
my myPlacePDF(myDoc, myLastPage, oneFile)
else if myFileType is "IDd4" or myExt is "indd" then
my myPlaceIndd(myDoc, myLastPage, oneFile)
else if myFileType is "W8BN" or myExt is "doc" then
my myPlaceDoc(myDoc, myLastPage, oneFile)
else
my myPlaceFile(myDoc, myLastPage, oneFile)
end if
end repeat
end tell
set user interaction level of script preferences to interact with all
end tell

on sort(the_list)
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10} ¬
-- always a linefeed
set list_string to (the_list as string)
set new_string to do shell script "echo " & quoted form of list_string ¬
& " | sort -f"
set new_list to (paragraphs of new_string)
set AppleScript's text item delimiters to old_delims
return new_list
end sort

on myPlaceFile(myDocument, myPage, myPfile)
tell application "Adobe InDesign CS3"
tell myDocument
try
set myPfilePage to place myPfile on myPage
on error
display dialog "Problem mit " & myPfile
end try
end tell
end tell
end myPlaceFile

on myPlaceDoc(myDocument, myPage, myDoc)
tell application "Adobe InDesign CS3"
tell myDocument
set myLeftMargin to left of (margin preferences of last page)
set myTopMargin to top of (margin preferences of last page)
place myDoc on myPage place point {myLeftMargin, myTopMargin} with autoflowing without showing options
end tell
end tell
end myPlaceDoc

on myPlaceIndd(myDocument, myPage, myINDD)
tell application "Adobe InDesign CS3"
set myDone to false
set myCounter to 1
repeat until myDone is true
tell myDocument
if myCounter > 1 then
set myPage to make page at after myPage
end if
end tell
set x to imported page attributes
set page number of imported page attributes to myCounter
get page number of imported page attributes
tell myPage
set myINDDPage to place myINDD
set myINDDPage to item 1 of myINDDPage
end tell
if myCounter = 1 then
set myFirstPage to page number of myINDDPage
else
if page number of myINDDPage = myFirstPage then
tell myPage to delete
set myDone to true
end if
end if
set myCounter to myCounter + 1
end repeat
end tell
end myPlaceIndd

on myPlacePDF(myDocument, myPage, myPDF)
tell application "Adobe InDesign CS3"
set myDone to false
set myPlacePoint to {0, 0}
set PDF crop of PDF place preferences to crop media
set myCounter to 1
repeat until myDone is true
tell myDocument
if myCounter > 1 then
set myPage to make page at after myPage
end if
end tell
set page number of PDF place preferences to myCounter
get page number of PDF place preferences
tell myPage
set myPDFPage to place myPDF place point myPlacePoint
set myPDFPage to item 1 of myPDFPage
end tell
get properties of PDF attributes of myPDFPage
if myCounter = 1 then
set myFirstPage to page number of PDF attributes of myPDFPage
else
if page number of PDF attributes of myPDFPage = myFirstPage then
tell myPage to delete
set myDone to true
end if
end if
set myCounter to myCounter + 1
end repeat
end tell
end myPlacePDF

on myGetPageNames(myDocument)
tell application "Adobe InDesign CS3"
set myPageNames to {}
repeat with myCounter from 1 to (count pages of myDocument)
copy name of page myCounter of myDocument to end of myPageNames
end repeat
return myPageNames
end tell
end myGetPageNames




Inhaltsverzeichnis











Powered by Movable Type 5.2.13