DTP


 
Lively discussions on the graphic arts and publishing — in print or on the web


Go Back   Desktop Publishing Forum > General Discussions > Print Production & Automation

Reply
 
Thread Tools Display Modes
Old 02-12-2005, 01:46 PM   #1
BradW
Sysop Emeritus
 
Join Date: Oct 2004
Posts: 76
Default Script to create InDesign libraries

It's nice to see so much activity in this section. I thought I'd contribute this AppleScript I've been using for the past couple of weeks in InDesign CS. It collects all the art in a folder and creates a new library, with each piece of art labeled and assigned the appropriate text runaround settings.

Before discussing what you might want to change in it for your own use, I want to thank Shane and Ray (and their AppleScripting Pro seminar) for their help in creating this.

In the second line of the script, where theLibFolder is defined, I've chosen to pick up the second-to-last word of the art folder because that's what makes sense for this job. The folders were called "Snacks art" and "Sandwiches art" so I wanted to pick up the descriptive word for use in the library name.

The section of the script that's labeled "-- add item label and text wrap settings" might also need to be customized, as I specifically wanted the text runaround of the images to use a contour wrap. I had already added clipping paths to the art, so with no docs open I set the runaround in InDesign to wrap three points from a Photoshop path, and that got picked up by the script (apparently).

Let me know if you have any questions, and I'm sure Shane or Ray will be able to answer them. ;-)

Brad
(who hopes that wrapping the script in code tags is a smart move)

--------

Code:
set theFolder to choose folder with prompt "Choose a folder of picture files:"
set theFolderPath to theFolder as Unicode text
set theLibFolder to word -2 of theFolderPath
set thefilenames to list folder theFolder without invisibles
set fileCount to count of thefilenames

tell application "InDesign CS"
	activate
	
	-- create and name library to selected folder name, create temp doc
	set theLib to make library with data {full name:(theFolderPath & theLibFolder & " art library.indl")}
	make document
	tell document 1
		
		-- create a page for each piece of art
		tell document preferences
			set pages per document to fileCount
		end tell
	end tell
	
	-- loop through art placement, styling, and library addition
	repeat with i from 1 to count of thefilenames
		tell document 1
			
			-- place the image
			set thisImage to place (theFolderPath & (item i of thefilenames)) on page i
			set thisLabel to (item i of thefilenames) as string
			set thisBox to parent of thisImage
			
			-- make its container fit
			fit thisBox given frame to content
			
			-- add item label and text wrap settings
			set properties of thisBox to {label:thisLabel}
			tell text wrap preferences of thisImage
				set text wrap type to contour
			end tell
			
			-- store item in library
			set storedItem to store theLib using page item 1 of page i
		end tell
		set libLabel to name of storedItem
		place asset asset libLabel of theLib on document 1
	end repeat
	
	beep
	with timeout of 10000 seconds
		display dialog "Finished." buttons {"OK"} default button 1
	end timeout
end tell
BradW is offline   Reply With Quote
Old 02-14-2005, 03:25 AM   #2
RayR
Member
 
Join Date: Feb 2005
Location: Northwest Georgia, US
Posts: 11
Default

Brad,

Nice job! Whenever I see an AS Pro alumnus use something like "word -2" it makes me very proud. <g>

FYI, I had dinner Thursday with Chris Ryland and Mark Neimann-Ross. The DTP forum was discussed (which I will share elsewhere eventually), and they both asked about you.

I'm glad to see you are finding AppleScript useful. Good work!

Ray Robertson
RayR is offline   Reply With Quote
Old 02-14-2005, 03:15 PM   #3
BradW
Sysop Emeritus
 
Join Date: Oct 2004
Posts: 76
Default

Thanks. This script has saved me a ton of time on this job. Today alone I used it to create three libraries comprising over 250 pieces of art, leaving me to just have to drag the images onto the pages and position them based on the layout.

To do the clipping paths, I set up an Action in Photoshop to use the magic wand, invert and expand the selection (since I used the enlarged path to knock out a rule that would need to look broken by the art), create the path, and save the file.

And then I made a Droplet that would run the Action when I dragged files onto it in the Finder!

If you talk to Chris and MNR again, let them know about the *new* DTP Forum. It looks like Kathleen, Elyse, and Ann (and the rest of the staff) have helped create a nice new home for us.

Brad
BradW is offline   Reply With Quote
Old 02-18-2005, 03:25 AM   #4
RayR
Member
 
Join Date: Feb 2005
Location: Northwest Georgia, US
Posts: 11
Default

Quote:
Originally Posted by BradW
And then I made a Droplet that would run the Action when I dragged files onto it in the Finder!
Cool. So you are scripting multiple apps already!

Quote:
Originally Posted by BradW
If you talk to Chris and MNR again, let them know about the *new* DTP Forum.
I did, and I agree that the new setup is nice. In my case, I just need to get in the habit of dropping by regularly.

Ray
RayR is offline   Reply With Quote
Old 02-18-2005, 03:22 PM   #5
BradW
Sysop Emeritus
 
Join Date: Oct 2004
Posts: 76
Default

Quote:
Originally Posted by RayR
Cool. So you are scripting multiple apps already!
I don't think I can get credit for "scripting" Photoshop, as I made the droplet by just poking around until I found a favorite-sounding menu item: Automate.

I'm starting an eight-book series in InDesign next month, and now I'm itching to find some excuse to script parts of it.

Quote:
Originally Posted by RayR
I did, and I agree that the new setup is nice. In my case, I just need to get in the habit of dropping by regularly.
Same here. It's just a fluke that I happened to catch your reply only 12 hours after you left it.

Brad
BradW is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FontAgentPro: export/import libraries? donat Fonts & Typography 13 02-28-2008 06:49 AM
[PR] Secure Powerpoint: create value from content Phil General Publishing Topics 3 02-17-2007 09:09 AM
indesign script yamisabel Print Production & Automation 2 01-26-2007 11:10 AM
PageMaker7.0 fails to create PDF Barbara Print Production & Automation 30 11-18-2006 09:52 AM
Create a round JPG? jwoolf09 Images 4 10-17-2006 12:14 PM


All times are GMT -8. The time now is 01:44 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Contents copyright 2004–2012 Desktop Publishing Forum and its members.