Some layouts are created in sections for example a document may have the following layout sequence 21, 23, 24,25. I have a process that allows the user to send off pages we need but I hit a bump and need a way to tell if a page has a section prefix.

If I try:

app.activeDocument.pages.itemByName("23").appliedSection.name

I get Object is invalid, but if I try

app.activeDocument.pages.itemByName("Sec1:23").appliedSection.name

I get Sec1: in the console.

So how can I test if there is a prefix?

I realize this will work but I need to check the page by the numbers entered by the user so

When the script runs page 21 its fine and works, 22 is fine as there is no page 22 and its captured, but 23 is there and should work but because it has a section prefix it needs to be myDocument.pages.item("Sec1:"+mySplitResult[myCounter]).name; to work.

hope this was correct. I did not seem to get anything back in the console unless I changed

if (pageName.search("Sec\\d+:" + pageNumber) != -1) {

to

if (pageName.search("Sec\\d+:" + pageNumber) == -1) {

This would return

2123242521232425212324252123242521232425undefined

I can see that you are expanding the pages entered by the user and then doing a search to see if a Sec prefix has been applied. Is this correct? If that's correct then could you search for just the number and if it is there it doesn't matter what the prefix is as the user may enter any name they wish for the prefix. If I'm understanding this correctly I like the method.

I think removing the prefix might be the best way to go. I have a feeling this might be a bug because if I run the following code for page 23:

app.activeDocument.pages.item(1).name

the console returns 23. So I then turn on the "Include prefix when numbering page" option in the numbering & section options panel and run the code again. This time I get Sec1:23. If I run your code it now returns Sec1:23 and Sec1:25.

The strange part is if I turn off the "Include prefix when numbering page" option and try the following code:

app.activeDocument.pages.itemByName ("23").name

I get Object is Invalid. If I run

app.activeDocument.pages.itemByName ("Sec1:23").name

It returns 23. Turn the option back on and then run the script again I get Sec1:23.

So is this a bug should app.activeDocument.pages.itemByName ("23").name return 23 I've tried both CS3 and CS5 and get the same result. It does not make sense to me. So I think removing the prefix might be the only option.

Yes, it's really weird to me that you always have to include section prefix when you are referencing page using itemByName() or item() — despite the fact that data browser shows name without prefix when "Include prefix when numbering page" is off.