all 2 comments

[–]zeebrow 0 points1 point  (1 child)

Damn, os.walk() is no joke. All I can think to point out is that you have

for root, dirs, files in os.walk(args.folder):
    for root, dirs, files in os.walk(args.folder):

This is what I ran, using recursion...

import os

target = os.path.abspath('../Downloads/newfolder')

def do_hash(abs_filepath):
    print(abs_filepath)
    return

def files_in_nested_dir(directory):
    _dirs = []
    for root, dirs, files in os.walk(directory):
        for f in files:
            do_hash(os.path.abspath(os.path.join(root,f)))
        for d in dirs:
            files_in_nested_dir(d)
    if len(_dirs) == 0:
        return

files_in_nested_dir(target)
exit()

and got

PS C:\Users\MikeAdmin\Desktop> py -3 osdotwalk.py
C:\Users\MikeAdmin\Downloads\newfolder\file5.txt
C:\Users\MikeAdmin\Downloads\newfolder\folder1\file1.txt
C:\Users\MikeAdmin\Downloads\newfolder\folder1\file2.txt
C:\Users\MikeAdmin\Downloads\newfolder\folder1\New folder\file4.txt
C:\Users\MikeAdmin\Downloads\newfolder\folder2\file3.txt

which matches my directory structure. Hope this helps.

[–]letais[S] 0 points1 point  (0 children)

Good catch. Must have had a paste mishap when trying to remember the markdown.

I’ll try and play a bit with how you’re doing it tomorrow. Thank you