Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Open with..." a file on Windows, with a python application

Tags:

python

windows

I am trying to figure out how to make a python program open a file when a user right clicks on the file and selects "Open With". For example, I want a user to be able right click on a text file and to select my program so that my program can process the text file. Is the name of the text file passed into my program someway? Thanks.

like image 263
osdev0 Avatar asked Nov 01 '11 03:11

osdev0


1 Answers

My approach is to use a redirect .bat file containing python someprogram.py %1. The %1 passes the file path into the python script which can be accessed with
from sys import argv argv[1]

like image 185
Roy Cai Avatar answered Nov 15 '22 18:11

Roy Cai