Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, os.path, sys
- if __name__ == "__main__":
- scriptlist = [ f for f in os.listdir('.') if f.endswith("ks") ]
- script = ""
- for f in scriptlist:
- sfile = open(f, 'r')
- script += sfile.read()
- sfile.close()
- wordcount = 0
- clickcount = 0
- # script = script.decode('utf_16_le')
- # script = script.replace(u"\ufeff", "")
- script = script.split('\r\n')
- for line in script:
- # if len(line) != 0 and line[0] not in u"*@;":
- clickcount += line.count("[pg]")
- while line.find("[") >= 0 and line[ line.find("[") + 1] != '[':
- a = line.find("[")
- b = line.find(']')
- while a > b:
- b = line.find("]", b+1)
- line = line[:a] + line[b+1:]
- if line.strip() != "":
- wordcount += len( line.split() )
- del script
- result = "This script has %d words." % wordcount
- result1 = "\nThis script has %d scenes." % clickcount
- print result
- print result1
- lint = open('%d_%d.txt' % (wordcount, clickcount), 'w')
- lint.write(result)
- lint.write(result1)
- lint.close()
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement