FAQ
I know this must have been asked before, but today Google is not my friend.

How do I do a "listdir" (or whatever I need to use) of the Desktop on a
Windows machine and have "folders" like My Documents show up in the
result?

I'm specifically trying to get a link to VMWare Shared Folders to show
up so I can navigate to files in OSX from WinXP running in VMWare, but
My Documents doesn't show up, either.

The docs for listdir says it doesn't follow links and I don't think I
want to tell os.walk to followlinks as that could be zillions of files.

Thanks!

Bob

Search Discussions

  • Tim Golden at Jun 3, 2010 at 3:57 pm

    On 03/06/2010 16:39, Bob Greschke wrote:
    How do I do a "listdir" (or whatever I need to use) of the Desktop on a
    Windows machine and have "folders" like My Documents show up in the result?

    I'm specifically trying to get a link to VMWare Shared Folders to show
    up so I can navigate to files in OSX from WinXP running in VMWare, but
    My Documents doesn't show up, either.

    The docs for listdir says it doesn't follow links and I don't think I
    want to tell os.walk to followlinks as that could be zillions of files.
    Depends exactly what '"folders" like My Documents' means (since I'm
    unfamiliar
    with VMWare Shared Folders) but you almost certainly want to use the Shell
    functions to walk the shell from the Desktop root. There was a short thread
    recently about it which I'll try to dig up (digs...):

    http://mail.python.org/pipermail/python-win32/2010-May/010475.html

    TJG
  • Bob Greschke at Jun 3, 2010 at 4:50 pm

    On 2010-06-03 09:57:11 -0600, Tim Golden <mail at timgolden.me.uk> said:
    On 03/06/2010 16:39, Bob Greschke wrote:
    How do I do a "listdir" (or whatever I need to use) of the Desktop on a
    Windows machine and have "folders" like My Documents show up in the result?

    I'm specifically trying to get a link to VMWare Shared Folders to show
    up so I can navigate to files in OSX from WinXP running in VMWare, but
    My Documents doesn't show up, either.

    The docs for listdir says it doesn't follow links and I don't think I
    want to tell os.walk to followlinks as that could be zillions of files.
    Depends exactly what '"folders" like My Documents' means (since I'm unfamiliar
    with VMWare Shared Folders) but you almost certainly want to use the Shell
    functions to walk the shell from the Desktop root. There was a short thread
    recently about it which I'll try to dig up (digs...):

    http://mail.python.org/pipermail/python-win32/2010-May/010475.html

    TJG
    Well, My Documents is not a normal folder. It's not the same as
    right-clicking and creating a new folder. I don't know what it is,
    exactly. VMWare Shared Folders seems to be a normal sort of link to
    '\\.host\Share Folders', but not quite, however, beyond that I'm not
    sure what it is. If I create Shortcuts to My Documents and VSF those
    show up with listdir, but I cannot follow them; Python does not think
    they are directories, which they aren't (they show up from listdir as
    'Shortcut to My Documents.lnk', for example).

    I'll take a look at the link above. Thanks!

    Bob
  • Christian Heimes at Jun 3, 2010 at 6:25 pm

    You're asking, it seems, for the equivalent of a UNIX softlink...
    Normal Windows doesn't support those (I think they are in the OS
    somewhere but not made visible to the user).
    Actually NTFS supports hard links, soft links and junction points since
    Windows 2k. [1]

    Christian

    [1] http://en.wikipedia.org/wiki/NTFS_reparse_point
  • Tim Golden at Jun 4, 2010 at 7:46 am

    On 03/06/2010 17:50, Bob Greschke wrote:
    On 2010-06-03 09:57:11 -0600, Tim Golden <mail at timgolden.me.uk> said:
    On 03/06/2010 16:39, Bob Greschke wrote:
    How do I do a "listdir" (or whatever I need to use) of the Desktop on a
    Windows machine and have "folders" like My Documents show up in the
    result?

    I'm specifically trying to get a link to VMWare Shared Folders to show
    up so I can navigate to files in OSX from WinXP running in VMWare, but
    My Documents doesn't show up, either.

    The docs for listdir says it doesn't follow links and I don't think I
    want to tell os.walk to followlinks as that could be zillions of files.
    Depends exactly what '"folders" like My Documents' means (since I'm
    unfamiliar
    with VMWare Shared Folders) but you almost certainly want to use the
    Shell
    functions to walk the shell from the Desktop root. There was a short
    thread
    recently about it which I'll try to dig up (digs...):

    http://mail.python.org/pipermail/python-win32/2010-May/010475.html

    TJG
    Well, My Documents is not a normal folder. It's not the same as
    right-clicking and creating a new folder. I don't know what it is,
    exactly.
    It's a shell folder. Which is what the code I pointed to deals with.

    VMWare Shared Folders seems to be a normal sort of link to
    '\\.host\Share Folders', but not quite, however, beyond that I'm not
    sure what it is.
    This would be the official starting point for reading up on the
    matter if you were motivated enough:

    http://msdn.microsoft.com/en-us/library/bb773177%28VS.85%29.aspx

    Basically, Windows has two "file systems" running in parallel
    and mostly, but not always, overlapping: the normal NTFS file
    system; and the Shell system. The NTFS file system starts from,
    say, c:\ and goes down from there. The Shell starts from the
    desktop and goes down from there. Obviously, under the covers,
    all shell objects have to be stored in some way on the file
    system. All NTFS files are represented within the Shell system;
    not all Shell objects are straightforwardly represented within
    the NTFS filesystem.

    If I create Shortcuts to My Documents and VSF those
    show up with listdir, but I cannot follow them; Python does not think
    they are directories, which they aren't (they show up from listdir as
    'Shortcut to My Documents.lnk', for example).
    Now you're talking about something slightly different. Windows has
    had Shortcuts since pretty much forever. They also are Shell objects
    and the shortcut-ness is only interpreted by the Shell, not by the
    filesystem. NTFS has had junctions and hardlinks since Win2K and now
    has symbolic links (which are implemented, I think, on the top of
    the uber-flexible Reparse Points) from Vista onwards. Both the Shell and
    the filesystem will follow these. Indeed you have to go out of your
    way *not* to follow them.

    Hopefully that explanation has helped (where it hasn't confused!).
    You might want to look at my winshell module (long overdue for
    an upgrade):

    http://timgolden.me.uk/python/winshell.html

    and at some of the articles on Mike Driscoll's Blog:


    http://www.blog.pythonlibrary.org/2010/02/25/creating-windows-shortcuts-with-python-part-ii/

    TJG

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 3, '10 at 3:39p
activeJun 4, '10 at 7:46a
posts5
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase