Question: I am new to shell scripting.How to overwrite the empty files in a directory using shell scripting?
Can anyone help me above question...

Answer: 
Assuming `All Users` is the name of the directory, you can remove the directory from your `subdirs` list, so that `os.walk()` does not iterate over it.

Example -

```
for path, subdirs, files in os.walk(root):
    if 'All Users' in subdirs:
        subdirs.remove('All Users')
    for name in files:
        if re.match(pattern, name.lower()):
                appendfile.write (os.path.join(path, name))
                appendfile.write ('\n')
                log(name)
                i=i+1

```

If you only want to *not walk* for `All Users` inside a particular parent, you can include the check for that as well in the above `if` condition.

From [`os.walk` documentation](https://docs.python.org/2/library/os.html#os.walk) -

> 
> **os.walk(top, topdown=True, onerror=None, followlinks=False)**
> 
> 
> Generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory top (including top itself), it yields a 3-tuple (dirpath, dirnames, filenames).
> 
> 
> When topdown is True, the caller can modify the dirnames list in-place (perhaps using del or slice assignment), and walk() will only recurse into the subdirectories whose names remain in dirnames; this can be used to prune the search, impose a specific order of visiting, or even to inform walk() about directories the caller creates or renames before it resumes walk() again. Modifying dirnames when topdown is False is ineffective, because in bottom-up mode the directories in dirnames are generated before dirpath itself is generated.
> 
> 
> 

`topdown` is normally true, unless specified otherwise.
if you have more than one directory to remove you can use a slice-assignment in oder to remove excluded directories in the `subdirs`

```
excl_dirs = {'All Users', 'some other dir'}

for path, dirnames, files in os.walk(root):
    dirnames[:] = [d for d in dirnames if d not in excl_dirs]
    ...

```

as [the documentation](https://docs.python.org/3/library/os.html#os.walk) states:

> 
> When `topdown` is `True`, the caller can modify the `dirnames` list in-place
>  (perhaps using `del` or slice assignment), and `walk()` will only recurse
>  into the subdirectories whose names remain in `dirnames`; ..
> 
> 
>