Question: I am writing a code in java which asks me to find the number of characters in sentence 1, sentence 2 and till the last sentence until the string/paragraph ends. I am actually able to get the number of characters in the whole string. But what i am supposed to get is how many characters are there in each sentence, inside a paragraph. For example inside a paragraph, the first sentence has 70 characters , second have 40 and so on. i think its related with period ending but don't know how to execute it.

Answer: 
You can use `os.walk` to scan all files in a directory.

```
import os

for root, dirs, files in os.walk('lang/'):
    for file in files:
        filename, extension = os.path.splitext(file)
        if extension == '.txt':
            # Do Some Task

```

Note that if you can filter by filename or file extension.

For example, if you want to get files that contains 'hello' in filename, you can also add

```
if 'hello' in filename:
    # Do Some Task

```
Try using a loop for this:

```
import os
def main():
    for dirName, subDirList, fileList in os.walk('path'):
        for subDir in subDirList:
            for file in fileList:
                #Do something with file
main()

```

This recursively goes through your files in a given directory. Note that this also goes through files in any other subdirectory in the parent directory. To instead ignore subdirectories do this:

```
import os
def main():
    for dirName, subDirList, fileList in os.walk('path'):
        for file in fileList:
            #Do something with file
main()

```

Of course you also have other [options](https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory).