Wednesday 15 January 2014

cmd - How to count characters in a text file using batch file -


I want to count all the characters in a certain lesson. Although in my code it only calculates a string but the requirement is to calculate all the letters including the blank space and the new line. For example:

  Hello World! how are you today? Hope you are ok  

How do I do this in my code? Thank you. My code:

  @ECHO OFF %% i in (y.txt) @ count count = %% ~ zi set REM "string" variable SET string = (Hello World Today I'm fine ..) // I want to read these strings because my code only reads single string REm "set string" variable set value of floating variable in the value of SET temp_str =% string% REM SET str_len = Start 0: Remove the character from the temporary strings variable defined by the loop and the increment before the counter counter. The value of temp_str is not empty until the empty string is in the loop. SET temp_str =% temp_str: ~ 1% SET / A str_len + = 1 geo loop) REM resonates the actual string value and its length. Echo% string is% straw_len% character long!  

All this, you need it:

 < Code> @ECHO OFF set / p "file = enter filename:" for %% i (% file%) in @ count count = %% ~ zi resonate this file% of the number% character white spaces and special characters such as Line-feed / cart-return etc.  

No comments:

Post a Comment