Skip to main content
Participating Frequently
March 17, 2024
Question

Script for count word in indesign save for file txt automatically named

  • March 17, 2024
  • 4 replies
  • 900 views

When we write literary novels, it is common for many words to be repeated, but this is a mistake. So we have to correct this, change it to synonyms, or even correct the sentence. In indesign, I need to generate a file that counts the occurrences of each word, in each chapter, as I am using the "book" system, so each chapter is a document, and I want to generate these documents containing the list of word occurrences, and export to Excel, where I can view the words that appear most often in the text and work to fix my text, novel. I got a script, very good by the way, but it always saves in a single file name, for example it always saves in "capitulo.yxt", and when I run it again, it overlaps the words, but the same file name remains, so To make it easier, I would like each time I run the file, it would add "01" or "02" to the end of the saved file, so it would be something like "capitulo01.txt", "capitulo02.txt". I don't know if I made myself understood.

This topic has been closed for replies.

4 replies

Marc Autret
Legend
March 18, 2024

Hi @xstranhox55805267 

 

Not sure this is relevant in your project but the script IndexMatic³ provides a Hits feature. The free version can report the 50 most repeated words, sorted by decreasing frequencies, and export results in TXT or CSV. You can also decide to exclude or include page numbers:

 

 

https://indiscripts.com/category/projects/IndexMatic

 

Best,

Marc

Community Expert
March 18, 2024

Ideally it should be a couple of line changes in your existing script. If you can't share the whole script share the portion where it creates the output file, search for things like "File", the filename i.e. "capitulo.txt" and share some lines around it here, we should be able to make the amends.

-Manan

-Manan
m1b
Community Expert
Community Expert
March 18, 2024

A good filename might be "<document name>_wordcount.txt". This way each file would be automatically unique and it would be very clear which document it had counted.

- Mark

PaoloVeronelli
Participating Frequently
March 17, 2024

Maybe it matters not only how often they happen but how near are the repetions.

m1b
Community Expert
Community Expert
March 17, 2024

Hi @xstranhox55805267, I think that probably won't be difficult for someone here. Are you able to post the script?

- Mark