# Re: Insert word count at end of the document

```On Sunday 04 April 2010 15:16:06 Kevin Li wrote:
> Hi,
>
> Is there a way to make the word count automatically appear at the end of
>  the document (perhaps like a variable)?
>
>
> Thanks, Kevin.
> ```
```
Certainly, if you're willing to use a script to generate the document. Have
something like this in the document prefix:

wordcount=32123

Then at the very end, put this ERT:

\wordcount

Then have a script that converts to text, counts the words via wc, then uses
sed to change the wordcount=32123 line, then converts to dvi via latex, and
converts to ps via dvips, then converts to pdf via ps2pdf.

I do stuff like this all the time. This is how my eBook personalization
scripts work.

SteeT

Steve Litt
Recession Relief Package
http://www.recession-relief.US