-1

I am trying to fetch the modified date and Author of the files in a folder.

import os PATH="my folder/books" my_list= os.listdir(PATH)

Let us suppose

customer details.xlsx

is one of the files in the books folder

How can i fetch the Author or Creator of the customer details.xlsx using os module of python?

Also i am able to fetch modified time by using os.path.getmtime(PATH/customer detalis.xlsx). But could not find the method for getting the Author.

jatin grover
  • 396
  • 1
  • 2
  • 10
  • Possible duplicate of [how to find the owner of a file or directory in python](https://stackoverflow.com/questions/1830618/how-to-find-the-owner-of-a-file-or-directory-in-python) –  May 04 '18 at 11:27
  • FYI, indent code blocks 4 spaces to format them properly –  May 04 '18 at 11:28

1 Answers1

0

This should work on UNIX:

import os, pwd

uid = os.stat("/path/to/file").st_uid
print pwd.getpwuid(uid).pw_name
Rafał Gajda
  • 151
  • 6