1

Is there a way to find the path of a user folder (desktop, downloads, etc...) if the folder was moved?

These don't lead to the correct path:

os.path.join(os.path.expanduser('~'), 'Desktop')
os.path.join(os.environ["HOMEPATH"], "Desktop")

Also, os.environ doesn't have any other key that will lead to the new path.

Moved folder

martineau
  • 119,623
  • 25
  • 170
  • 301
Nir
  • 894
  • 3
  • 13
  • 24
  • [this](http://stackoverflow.com/a/30924555/3714940) works for me. Putting the code in a loop showed that `CSIDL_PERSONAL = 16` for `Desktop`. Although, `Downloads` didn't appear, so maybe this isn't quite the complete solution – SiHa Sep 13 '16 at 15:35
  • @SiHa As I've stated in my question, os.expanduser('~') leads to a different path than the custom path I've set. – Nir Sep 13 '16 at 15:36
  • Look at the answer I've linked in my comment, this is a different solution that doesn't rely on `'~'` – SiHa Sep 13 '16 at 15:36
  • Thanks. I did, but it looks ugly. Isn't there a simpler way? – Nir Sep 13 '16 at 15:37
  • 1
    @Nir, no, you'll have to do some kind of WinAPI call. Wrap ctypes / cffi / pywin32 extension call with some function and forget about how complicated it is. Any other library would have to do exactly the same. – Łukasz Rogalski Sep 13 '16 at 17:11

0 Answers0