1

I am trying to get the media created datetime of a file using python, with reference to this question, Python - how to read Windows "Media Created" date (not file creation date), I have successfully gotten the media created datetime from the answer provided by https://stackoverflow.com/users/205580/eryksun

However, the action following that is os.rename(file_i_got_media_created_datetime_from, destination_path), which will not execute, no error is shown. I have figured out after hours that this may be because properties = propsys.SHGetPropertyStoreFromParsingName(filepath) still holds a reference to the file, thus os.rename cannot proceed to rename without that reference from being released.

I would like to know how i can release this reference/pointer to the file so that it can be released for os.rename to do its job.

Btw i have googled extensively on pythoncom and havent got a clue as to how to do this, the documentation isn't rly clear and not much tutorials on the lib.

EDIT: I used the del keyword to delete the variable properties which removed the reference and it worked.

1 Answers1

0

just set properties = None and once the object is released, the file handle will be closed. I tried with my script and worked

capaneus
  • 103
  • 1
  • 6