1

I have been using the replies from here to read out the metadata of files on windows. However i noticed that it would just ignore hidden files.

How can one also include hidden files in this approach?

1 Answer 1

1

You can combine python's os library with Windows' Shell.Application object, as done here, something like this:

import os
import win32com.client

sh = win32com.client.gencache.EnsureDispatch('Shell.Application', 0)
path = r'c:\mypath\myfolder'
ns = sh.NameSpace(path)

colnum = 0
columns = []
while True:
    colname=ns.GetDetailsOf(None, colnum)
    if not colname:
        break
    columns.append(colname)
    colnum += 1

for name in os.listdir(path): # list all files
    print(path + '\\' + name)
    item = ns.ParseName(name)
    for colnum in range(len(columns)):
        colval=ns.GetDetailsOf(item, colnum)
        if colval:
            print('\t', columns[colnum], colval)

hidden files will display (H attribute is for Hidden)

...
Attributes HA
...
Sign up to request clarification or add additional context in comments.

2 Comments

I probably should have thought of that myself... instead i went digging around here learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/…. Thanks so much!
@J.N. - Shell.Application is a wrapper over these native API and interfaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.