Python: How to get internal directory structure of Outlook PST file?
Question: Is there any Library for Python (Windows) to read the Internal Directory
structure of PST file eg. Inbox, Drafts, etc including Folders created by
Users.


Answer: as per <https://support.microsoft.com/en-us/kb/287070>

> Microsoft Outlook automatically stores messages, contacts, appointments,
> tasks, notes, and journal entries in one of the following two locations: In
> a personal storage folder, also known as a .pst file, on your hard disk
> drive. In a mailbox that is located on the server. Your mailbox is located
> on a server if you use Outlook with Microsoft Exchange Server.

so, based on this info, you should be able to use OS

    
    
    import os
    

documentation for the library is here:
<https://docs.python.org/3/library/os.html>

The following example shows a simple use of scandir() to display all the files
(excluding directories) in the given path that don’t start with '.'. The
entry.is_file() call will generally not make an additional system call:

    
    
    for entry in os.scandir(path):
       if not entry.name.startswith('.') and entry.is_file():
           print(entry.name)
    

for validating directories: using listdir(path) lists available directories
within the specified path, adding further logic, you should be able to achieve
what you want Ex:

    
    
    import os
    
    cdirs = os.listdir("C:/")
    
    print(cdirs)
    

or create a function to do this:

    
    
     def file_check(path):
            file_dirs = listdir(path)
            #do something with this
    
            return file_dirs
    

