🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20662

AppleSript: From Toast/iTunes to InDesign

#20662
From: Kari Puikkonen
Date: Mon, 01 Jul 2002 16:21
101 lines
4330 bytes
Hoohah! 

I've compiled two scripts that exports the playlist/tracklist information either from the Toast or from the iTunes and pastes it to the InDesign with formatting. The choice is yours... 

These scripts are based on sample scripts by Apple, Elias Keshishoglou and everybody on this forum, like Shane Stanley, Olav Martin Kvern etc... Thanks for the help and advise! 

First one is the script that exports Audio CD title and tracklist information from the Toast - via clipboard, pastes it to the InDesign and formats the resulting text frame.  
You need to have InDesign document open with one empty text frame (for example 11 cm x 11 cm, so you can use the result as CD cover) which does not need to be selected. Also you need two paragraph styles; "Title" and "Songs", which you can format beforehand to your taste (for example to the kind of which you can use as a CD cover). 

-- Go and get the Tracks and Title from Toast. 
set myTracks to GetNamesFromToast() 

tell application "InDesign 2.0.1" 
	-- Tell  InDesign to become the active application. 
	activate 

	-- Fill the Clipboard with the track data. 
	set the clipboard to myTracks 

end tell 

-- Get the information from Toast. 
-- NumTracks contains the number of tracks on the CD. 
-- myCDTitle is the title of the CD. 
-- myTracks contains a list of the track names. 

on GetNamesFromToast() 
	tell application "Toast Titanium 5.1.2" 

		-- Set the first items of myTracks to be the CD Title.		 
		set myTracks to (the title of the current disc) & return 

		-- Ask toast to tell us the number of tracks. 
		set NumTracks to the number of audio tracks of current disc 

		-- Go and get each track and add it to thisTrack, 
		-- then we will add it to myTracks. 
		repeat with myIndex from 1 to NumTracks 
			-- Get the track name from Toast 
			set thisTrack to audiotrack myIndex of the current disc 

			-- Add the track number and ) before the string 
			-- You can remove this line if you do not want the numbers. 
			set thisTrack to (myIndex as string) & ") " & thisTrack 

			-- Add the new name to the list. 
			set myTracks to myTracks & return & thisTrack 
		end repeat 

	end tell 
	return myTracks 
end GetNamesFromToast 

tell application "InDesign 2.0.1" 

	--Get a reference to a text frame   
	set myTextFrame to text frame 1 of page 1 of active document 
	set myStory to parent story of myTextFrame 
	set myInsertionPoint to insertion point 1 of myStory 

	tell document 1 

		--Select the insertion point  
		select myInsertionPoint 
		paste 

		set theSongs to paragraph style "Songs" 
		set theTitle to paragraph style "Title" 

		tell text frame 1 
			tell parent story 
				repeat while (get character -1) = return 
					delete character -1 
				end repeat 
				set applied paragraph style of paragraphs to theSongs 
				set applied paragraph style of paragraph 1 to theTitle 
				set theOffset to index of paragraph 2 
			end tell 
			set startTrack to -1 
			set endTrack to -20 
			repeat while (get overflows) is true 
				set tracking of parent story to startTrack 
				set startTrack to startTrack - 1 
				if startTrack = endTrack then 
					exit repeat 
				end if 
			end repeat 
			set startSize to 11 
			set endSize to 7 
			repeat while (get overflows) is true 
				set point size of text from character theOffset to character -1 of parent story to startSize 
				set startSize to startSize - 0.25 
				if startSize = endSize then 
					exit repeat 
				end if 
			end repeat 
		end tell 
	end tell 
end tell 

Continue in Part II
Technical Details
Message-ID: <ef96c33.-1@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!diablo.theplanet.net!newsfeed.esat.net!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,78322622044f6402,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-07-01 09:38:12 PST
From: "Kari Puikkonen" <kari.puikkonen@welho.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!diablo.theplanet.net!newsfeed.esat.net!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: AppleSript: From Toast/iTunes to InDesign
Message-ID: <ef96c33.-1@WebX.aaQKaf7vad4>
Date: Mon, 1 Jul 2002 09:21:18 -0700
Lines: 117
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit