I am using:
for root, dirs, files in os.walk(rootDir):
to navigate around directories. All cool. However, I am running on windows 7 which of course has the library abstraction. So for example the picture library might map to c:\users\me
and c:\users\share
Is there any way I can use this library abstraction with python?
Unless I'm wrong about how this feature works (I don't actually have a Win7 box in front of me), you will have to access the Windows Shell APIs in order to access libraries.
Reading Introducing Libraries from MSDN Magazine, it seems pretty clear that apps that just deal with the filesystem will see a library as just a regular directory, and not even have any indication of the various scattered directories that make up the library. Unless you always stick to the fancy file-chooser dialogs to get all paths (in which case the user sees libraries, but always ends up picking a specific folder, so you don't have to deal with libraries), you have to explicitly use the shell APIs.
I think you want to start at Windows Libraries for the dev guide and IShellLibrary for the reference.
These are obviously COM APIs, so you probably want to use win32com
to access them from Python. (You could use ctypes
and deal with the COM stuff C-style, but you really don't want to.) It's possible that someone has already wrapped up these COM objects in a nice Python interface—I didn't find anything in quick PyPI and ActiveState searches, but you might want to try a more serious search.
Alternatively, of course, you could use IronPython and use the .NET APIs instead of the native ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With