Article View: adobe.scripting.indesign
Article #17566Re: AppleScript: Import tifs one on each page???
From: Olav Kvern
Date: Thu, 29 May 2003 17:56
Date: Thu, 29 May 2003 17:56
77 lines
4158 bytes
4158 bytes
Christopher--
I couldn't find it, myself, so I'll post it again. Also, it needed some updates for OS X.
--PlaceAllFilesFromFolder
--This script attempts to place all files found in a specified folder.
--If you don't want to remove empty frames, set myRemoveEmptyFrames to false.
--(Set this value to false if you are placing one file per page!)
set myRemoveEmptyFrames to false
--Set up the page layout by entering the number of rows and columns you want.
set myNumberOfRows to 1
set myNumberOfColumns to 1
set myFramesPerPage to (myNumberOfRows * myNumberOfColumns)
--Display a "Choose Folder" dialog box.
set myFolder to choose folder with prompt "Select the folder containing the files you want to place."
tell application "Finder"
set myFiles to files of myFolder
set myNumberOfFrames to (count myFiles)
--The sort method is not yet available for the OSX Finder. Make sure that the files in the folder
--are sorted in the order in which you want them to appear.
--Uncomment this line if you're using OS 9.
--set myFiles to sort files of myFolder by name
end tell
tell application "InDesign 2.0.2"
set myDocument to make document
set myDocumentPreferences to document preferences of myDocument
set myNumberOfPages to round (myNumberOfFrames / myFramesPerPage) rounding up
set pages per spread of myDocumentPreferences to 1
set pages per document of myDocumentPreferences to myNumberOfPages
set myMarginPreferences to margin preferences of page 1 of myDocument
set myLeftMargin to margin left of myMarginPreferences
set myRightMargin to margin right of myMarginPreferences
set myTopMargin to margin top of myMarginPreferences
set myBottomMargin to margin bottom of myMarginPreferences
set myLiveWidth to (page width of myDocumentPreferences) - (myLeftMargin + myRightMargin)
set myLiveHeight to (page height of myDocumentPreferences) - (myTopMargin + myBottomMargin)
set myFrameWidth to (myLiveWidth / myNumberOfColumns)
set myFrameHeight to (myLiveHeight / myNumberOfRows)
set myPages to pages of myDocument
repeat with myCounter from (count myPages) to 1 by -1
set myPage to item myCounter of myPages
repeat with myRowCounter from myNumberOfRows to 1 by -1
set myY1 to myTopMargin + (myFrameHeight * (myRowCounter - 1))
set myY2 to myTopMargin + (myFrameHeight * myRowCounter)
repeat with myColumnCounter from myNumberOfColumns to 1 by -1
set myX1 to myLeftMargin + (myFrameWidth * (myColumnCounter - 1))
set myX2 to myLeftMargin + (myFrameWidth * myColumnCounter)
tell myPage to make rectangle with properties {geometric bounds:{myY1, myX1, myY2, myX2}}
end repeat
end repeat
end repeat
repeat with myCounter from 1 to myNumberOfFrames
set myFileName to item myCounter of myFiles as string
set myRectangle to rectangle myCounter of myDocument
tell myRectangle
place myFileName
end tell
fit myRectangle given content to frame
fit myRectangle given proportionally
end repeat
if myRemoveEmptyFrames is true then
tell myDocument
tell (every rectangle whose content type is not graphic) to delete
end tell
end if
end tell
(Also, I'm kind of an anime/manga nut--what are you working on? I'd be happy to trade scripting for copies.<g>)
Thanks,
Ole
Technical Details
Message-ID:
<1de950d8.1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de950d8.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,b057cd3b108c84c5 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-05-29 11:08:44 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: AppleScript: Import tifs one on each page??? Message-ID: <1de950d8.1@WebX.la2eafNXanI> Date: Thu, 29 May 2003 10:56:57 -0700 References: <1de950d8.-1@WebX.la2eafNXanI> Lines: 83 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit