Welcome to WebmasterWorld Guest from 126.96.36.199
If you do it dynamically, you'll need to guard against malicious remote file inclusion, in the code that processes incoming requests for the gallery pages.
The page titles are between <title> and </title> tags in the source code. You'll need to open the files and use regular expressions to extract what's between those tags in each page.
Assuming the IDs match the filenames, you can get a list of them by getting a directory listing. If you generate the IDs in a loop, you'll just need to check to see if each possible numeric ID matches an existing file; if it does, open it and get the <title> contents.
However, I ran the idea by my boss and he said that the last time a robot (which this is essentially) tried to index all our galleries it screwed up the system and skewed the site statistics, so I've pretty much been told to abandon this plan. Thanks for the help though!
If a static index page is acceptable, then you can probably create some automated methods similar to what I described, that will help create ID/title pairs which you can then put on a static index page for use on the live site. I.e. you would run that program only once to help you build the static page, then upload the page you created to the server.