The count_words command-line utility counts the words and characters in the specified files, and writes the counts to a text file in a table format, one row per
file, with a total at the bottom. The syntax is as follows:
count_words.py [-h] [-o outfile] -f filename [filename ...]
- -o
- The output file (optional) (default is 'wordcount.txt').
- -f
- One or more files to process
- -h
- Show help for this command
Example:
count_words -o wordcount.txt -f wordfile.doc excelfile.xls pptfile.ppt
Write a formatted wordcount for the files "wordfile.doc", "excelfile.xls", and "pptfile.ppt" to the file wordcount.txt
Here is the output for the command count_words -o wordcount.txt -f MITLicense.txt MITLicenseJ.txt README.txt
File Words Chars Chars (no spaces) Double Byte Non-Asian Words MITLicense.txt 168 1,065 902 0 168 MITLicenseJ.txt 463 505 501 457 6 README.txt 7,650 53,345 41,952 0 7,650 ======================================================================================= Total 8,281 54,915 43,355 457 7,824