How to get an application's version on macOS?

Question:

I am writing a simple script using python to be used on macOS BigSur. I was wondering if there is a way to find the version of an application using python. I know it’s possible on Windows using PyWin32 library, however, I could not find anything for MacOS.

Asked By: Mohammad

||

Answers:

Thanks @sudden_appearance for the approach

import os
stream = os.popen('mdls -raw -name kMDItemVersion /Applications/Firefox.app')
targetVer = stream.read()
print(targetVer)
Answered By: Mohammad
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.