It's probably scriptable, but be warned, when you create outlines this way you do a number of very bad things. First you lose any future editabilty of your text. Second, you lose hinting on the font becasuse it is no longer text, so it looks bolder. Third, you lose all adornments like underlines and paragraph rules. Fourth, you lose all automated bullets and numbering.

In modern workflows there is essentially no valid reason for conversion to outlines as fonts should be embedded in your PDF. If you absolutely need to convert the text to outlines you are better to do it by making sure there is transparency interaction on every page and using a custom flattener setting that converts to outlines during export.