All you do is open Applescript or Javascript, copy Carlos' text and paste it into your new script file. Save that in CS5's Scripts folder or wherever you want. When using the script you go to the file menu - Scripts - Other Scripts and navigate to your new script and viola!

"Hi Paal, the script is the text in colors below the image, copy starting from "#target illustrator" all the way down to the last closing bracket "}", then open the ESTK or any text editor, paste it there and save it with a sugested name "UI_insertPageNumbers.jsx" or any other name. Make sure you save it with a "JSX" extension. Save it in you default "scripts" folder and it will show in the Illustrator "File->Scripts" menu, next time you restart illustrator."

I tested this out and here are some of my findings:

I pasted the code into the default TextEdit mac text editor. Format -> Make Plain Text. Saved it as a .jsx file.

Placed the file into Adobe Illustrator CS5 -> Scripting.

Reopened Illustrator. Opened a file (you need to open a file first). Looked in the File -> Scripts (it was not visible) -> Other Scripts and found the file.

A dialog box opens and you can test out how it works.

To get page numbers remove the text in the box and click Insert Page.

A follow up to this wonderful script.

What about changing the font and size of the page numbers?

Thank you for the script Carlos! Hopefully Adobe can purchase it from you and add to to the next version.

Copy the above text. Open a text editor which can save a plain text file (or the Adobe ESTK [ExtendScript ToolKit]) and paste the text. Save it as a plain text file with a .jsx file extension. Move the file to Applications/Adobe Illustrator CS4 or CS5/Presets/en_US/Scripts and restart your AI app. This is an ExtendScript file and will not work in the AppleScript editor.

You cn also go the the Utilities Folder in the Application Folder and use the Adobe Utilties>Extended Script Tool to complie the script by pasting ther as well and do a save as the .jsx is the dfault so not much thinking is required.

Perhaps Carlos can create a default paragraph style -- or lets the user select an existing one -- and apply that?

well, the script uses "the" default paragraph style. Selecting an existing paragraph style sounds doable, but wouldn't it be the same as selecting it in Illustrator?....Unless after applying it, the text gets out of place.

Honestly, due to limitations of both Character and Paragraph styles in Illustrator I'd strongly reccommend not including them. Once a style in Illustrator is set, there's absolutely no way to break the link to the style. Better to not have a style than a style you can't strip from the text in my opinion.

Thanks for this Carlos. The script works, however, I am unable to close the window as it has no close window button and so have to force quit Illustrator, thereby making it impossible to save what this wonderful script does. I'm on a Mac, using CS6. Any ideas how to close the script window after running it?