InDesign pages script problem


I have to devide documents into new documents containing each only one spread from original.
I have a script from a friend that perfectly works, but … I need to fix the old page numbering for the new documents.
Can anybody complete my script? This would be great.

tell application “Adobe InDesign CS2”
set myFile to full name of active document
set myPath to file path of active document as string
set myDocName to name of active document
set nSpreads to count spreads in active document

if nSpreads > 1 then
	repeat with n from 1 to nSpreads
		tell application "Finder" to set nuFile to duplicate myFile
		set nuName to myDocName
		if nuName ends with ".indd" then
			set nuName to characters 1 thru -6 of nuName as string
		end if
		set nuName to nuName & n & ".indd"
		set nuSaveFile to myPath & nuName
		open nuFile
		set myCopy to active document
		set allow page shuffle of document preferences of myCopy to false
		if n < nSpreads then
			delete spreads (n + 1) thru nSpreads of myCopy
		end if
		if n > 1 then
			delete spreads 1 thru (n - 1) of myCopy
		end if
		save myCopy to nuSaveFile
		close active document
		tell application "Finder" to delete nuFile
	end repeat
end if

end tell

Hi Sabine,

why not just something like this

tell application "Adobe InDesign CS2"
	tell document 1
		delete ( spreads 2 thru 10 ) -- here your own numbers
	end tell
end tell

and then just save each time as a new doc, the page numbers are automatically arrenged
then maybe you can tell active doc to revert

just an idea

Carlos Ysunza

Model: G5
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)


but I do not want to loose the original numbering. I want to do it all automatically. If I have one document containing 6 spreads with page number 1 to 8 then I want to get 6 documents. The fist ist page number one. The sencond doc has page number 2 and 3 and so on.
So the script I have does half of the work. Now I have to tell InDesign not to use the automatic page numbers but to create new sections for every spread with the correct page number to start.