How to get which file is requested to open using a mac application?

Posted by ramsey on Super User See other posts from Super User or by ramsey
Published on 2012-09-27T14:02:32Z Indexed on 2012/09/27 15:40 UTC
Read the original article Hit count: 273

Filed under:
|
|
|
|

i have created an mac application which can be open my file extensions.

But when i tested it, i dont get the path of the file requested to open using the application,

instead i got the "psn_0_151589".

I checked it for itunes, textedit, xcode and other applications.

Below is my app sample main code where i process path of the opened file

python code

import sys
import os.path

print("File opened with this app :: ",sys.argv[1])

if(os.path.exists(sys.argv[1]):
print("valid file :: { do something...}\n")
else:
print("Invalid file path received :: { do nothing }\n")

OUTPUT :

File opened with this app :: psn_0_151589

Invalid file path received :: { do nothing }

Hope someone knows how to get the filepath which was opened using any application.

Any help would be greatly appreciated.

-ramsey

© Super User or respective owner

Related posts about osx

Related posts about mac