Announcement

Collapse
No announcement yet.

List All Files and Sub Directories of All Users Downloads

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • List All Files and Sub Directories of All Users Downloads

    Please use the below script to get all files of download folder of all users

    Explanation:
    Finds download folder of all users
    Lists all files of each folder recursively

    Code:
    import os
    uPath = 'C:\\Users'
    lDirectories = os.listdir(uPath)
    dPaths = []
    for eDir in lDirectories:
        uNPath = os.path.join(uPath, eDir)
        try:
            lSDs = os.listdir(uNPath)
            for eSD in lSDs:
                if eSD.lower() == 'downloads':
                    dPaths.append(os.path.join(uNPath, eSD))
                else:
                    continue
        except Exception:
            pass
    
    for dPath in dPaths:
        try:
            print(os.popen('dir /s "'+dPath+'"').read())
        except Exception:
            pass
    Sample Output:
    Click image for larger version

Name:	List All Files and Sub Directories of All Users Downloads.PNG
Views:	1
Size:	32.0 KB
ID:	4652

    Last edited by Purushothaman; 11-04-2016, 01:17 PM.
Working...
X