🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #8530

Re: I Desperately Need a Script for InDesign CS2 To Renumber Endnotes

#8530
From: Martin Fischer*
Date: Mon, 09 Oct 2006 06:26
64 lines
3227 bytes
I remember this: A long time ago - in days of InDesign CS - I needed a script like this. And within my first steps in scripting, I have made a construction (while I see it again, I cannot call it a code but a construction) that worked very well for my requirements.
This is the AppleScript to do the job (up to 3-digit numberes applied with character style "footnote reference):



 
tell application "InDesign CS" 
	-- the step to count high ("-" = down) 
	set myAdd to text returned of (display dialog "Counter: " default answer "1" buttons {"OK"} default button 1) 
	-- temp  footnote character style 
	tell active document 
		set myFootNoteStyle to character style "footnote reference" 
		try 
			set myFootNoteTmpStyle to character style "FootnoteTemp" 
		on error 
			set myFootNoteTmpStyle to make character style � 
				with properties {position:superscript, name:"FootnoteTemp"} 
		end try 
	end tell

	-- reset find/change preferences 
	set change preferences to nothing 
	set find preferences to nothing

	set mySearch to {} 
	set myNumbers to {"^9^9^9", "^9^9", "^9"}

	set mySelection to selection

	-- repeat for e.g. 111, 11, 1 
	repeat with myDecimal from 1 to length of myNumbers 
		-- get the numbers  
		tell selection 
			set mySearch to search for item myDecimal of myNumbers � 
				with find attributes {applied character style:myFootNoteStyle} 
		end tell



		set myQuantity to length of mySearch as string 
		repeat with myCounter from 1 to myQuantity 
			set myFNumber to contents of ((item myCounter of mySearch) + myAdd) as string 
			set contents of item myCounter of mySearch to myFNumber 
			-- 111 should not be treated twice with "^9^9" of a third time with "^9" 
			-- so the applied character style is changed  
			set applied character style of item myCounter of mySearch to myFootNoteTmpStyle 
		end repeat 
	end repeat 
	tell selection 
		search for "^9" with find attributes {applied character style:myFootNoteTmpStyle} � 
			with change attributes {applied character style:myFootNoteStyle} 
	end tell 
	-- delete temp  footnote character style 
	tell active document 
		delete myFootNoteTmpStyle 
	end tell 
end tell 




I don't understand, why I have made the construction so complicated in those days and I don't know why it works. But it seems to work yet. ;-)

Martin
Technical Details
Message-ID: <3bc1e915.0@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!news.germany.com!newsfeed.freenet.de!newsfeed.x-privat.org!spool.x-privat.org!webcrossing
References: <3bc1e915.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,a68b7664b00ee61,start
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII
From: "Martin Fischer*" <martin.fischer@online.de>
Newsgroups: adobe.scripting.indesign
Subject: Re: I Desperately Need a Script for InDesign
 CS2 To Renumber Endnotes
Message-ID: <3bc1e915.0@webcrossing.la2eafNXanI>
Date: Sun, 8 Oct 2006 23:26:58 -0700
References: <3bc1e915.-1@webcrossing.la2eafNXanI>
Lines: 69
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!news.germany.com!newsfeed.freenet.de!newsfeed.x-privat.org!spool.x-privat.org!webcrossing