So, this is a very specific question, and I have the windows version so I figured I’d ask here
Is the current word count of a project saved in the project file anywhere? I’d like to be able to have a program access the word count and report it to something else (my phone) through a script. But that’s all impossible if it’s not saved anywhere.
Any ideas? Thanks!
This isn’t stored anywhere on the disk, unfortunately. It is assembled dynamically and would require a good understanding of how all the project files are glued together, to calculate it. If you’re good at scripting and XML, you can take a crack at it by studying the scrivx file. Basically you would need to isolate all of the ID numbers that descend out of the root Draft item (that are marked with “Include in Compile” set to true), and then use that list of ID numbers to grab the nodes in the search.indexes file. That is roughly how Scrivener itself does it, though you should be aware that at the moment the search.indexes file can be a bit unreliable on Windows (it’s a bug, but it doesn’t impact everyone so it’s worth a shot). If it does turn out to be unreliable, it would be more accurate to scan all of the RTF files in the Files/Docs folder by ID number. Assuming you have a way of extracting pure text out of an RTF file, that would work, if a bit slower.