Wednesday, 29 January 2014

Google drive scripts

I use Google docs (sorry, I am so old school) Google Drive to post chapters for my betas to check. We can all access a document, once I have granted them permission and vice versa for me with their documents. We can even chat if we are in the document at the same time. It’s a great system and it works well for us. We have fallen into a colour coded pattern where each of us uses the same colour so that the doc owner knows who made which comment.
My big issue with Google Drive is that it has no running total word count. I know I can press ctrl/shift/C and get the number of words in the document, or the part I have selected, but I can’t add a sentence here, a word there and a big bit in the middle and know how many words I just added.
I have searched for a long time to find something that would do that. I did find a program on greasemonkey but I don’t trust the maker and there are not enough comments from people to say whether it worked for them (or not) for me to be installing a program that allows access to my documents.
I use a program called Evernote to copy web pages. It is very neat and very useful when I am researching a topic. It is all stored in the cloud, with urls, text and images etc and I lose nothing if disaster happens. Plus, it starts to auto tag stuff. Oh, this should go in ‘fic ideas’ marked ‘succubus’. Yes, it should. Pats Evernote. It also synchs with your phone.
The Evernote ambassador is Jamie Todd Rubin, a scifi author who writes computer code as a day job. He loves spreadsheets and being super organised. Recently he shared his basic code for a Google doc word counter that works with Evernote.
I read it and it looked perfect for me. I took a deep breath. I am not techie. And I love the way that people who deal with code all the time say ‘it’s so easy’… sure, it is.
As I understand the code, you write in a particular folder. At the end of the day, the script makes a copy of what you have written and puts it into a different folder. It compares it with yesterday’s copy and counts the number of words added and posts that total into another spreadsheet under the date. It then emails to my Evernote address, a copy of what was added.
As a writer this is neat. I am always terrified that I will edit and ruin something. It would effectively give me daily backup copies. Bonus!
To use this code, I had to install goggle scripts, copy in more than a thousand lines of code on two pages and make some adjustments - my email address, time zone, document names and so on. But I couldn’t get it to work. Test runs failed at a particular line. It took me long enough to work out how to do a test run! Jamie said he doesn’t have time to help people get it to work and that is fair enough; he’s busy.
I did some research. I read up on Scripts and I changed one line of code and voila! (I had to change the spreadsheet to find by url not id#. If I ever move that spreadsheet it will fail again. Note to self: do not move spreadsheet.)
Today I got an email and a line of numbers in my spreadsheet. And I am so proud of myself.

No comments:

Post a Comment