0

Is it possible to get the GUID of a file in Python?

This article shows how to create one in C, but I don't know how to translate it to Python.

Here is the reason why I need it. If you think there is a better way to solve my problem, please answer (and I will change the title if necessary).

I have a database table with one column containing file path names. The records become useless when a file or a folder is renamed.

I thought about adding a column with the GUID of the file. Then when a function is called with the path name, if the record with the path name is missing, the function will get the GUID from the file and search in the table by GUID.

stenci
  • 8,290
  • 14
  • 64
  • 104
  • The article you quote is using Windows syscalls -- are you on Windows, and using the right kind of filesystem too? If so, please tag the Q appropriately, and check if the `win32` package offers the myriad specific syscalls you'll need to transliterate that C to Python. Unless you're specifically on Windows with NTFS (not FAT32) filesystems, I think you're out of luck (I don't think other OSs offer functionality of this kind, except, as noted in the comments to the article you link, some ancient ones like the `Apollo` OS). – Alex Martelli Jan 07 '15 at 02:19
  • @AlexMartelli: It looks like I'm lucky: it is NTFS and this page looks promising: http://timgolden.me.uk/pywin32-docs/win32file__DeviceIoControl_meth.html. Tomorrow I will try to translate the example from the article and see how far I get. As a side note I'm talking about thinkdesign files, that you should know well! I was in QA in Bologna shortly before you left think3 :) – stenci Jan 07 '15 at 03:32
  • Hi @stenci, funny we should overlap in our think3 employment histories! Send me a Linkedin invite and let's connect there, I try to connect to all my long-ago think3 colleagues... – Alex Martelli Jan 07 '15 at 03:37

1 Answers1

0

While translating this function to Python I found the answer to my question in this post.

Community
  • 1
  • 1
stenci
  • 8,290
  • 14
  • 64
  • 104