Image

Imageguberif wrote in Imagepython_dev

Windows: Follow-up; how to associate some random file with a python script

So you have this file with a specific extension that you want opened by a python program when you double-click it. It's not as straightforward as associating it with the python script in the windows Open With dialog box.




  • Go to Start->Settings->Control Panel.
  • Select Folder Options.
  • Select File Types tab.
  • Hit the New button.
  • Enter the file name extension that your Python script handles, then hit OK.
  • Make sure your new extension is selected in the "File Type" list, then hit the "Advanced" button.
  • In the first(unlabeled) text entry box, you can enter a long description for the file type - hitting the Change Icon button will allow you to change the icon for this file type.
  • Hit the "New" button.
  • In the text entry box labeled "Action:" type the word "open" without quotes - this is apparently some sort of Windows keyword in this context.
  • In the text entry box labeled "Application used to perform action:" enter: <absolute path to python interpreter> <absolute path to python script that will handle the file type> %1
    • In my case, it looks like this: 'C:\Python24\pythonw.exe "C:\Documents and Settings\guberif\Desktop\association_test.py" %1' ** ***
  • Hit OK.
  • Hit Close.
  • You're done.
  • Have a nice day.
  • There are no further instructions.



*Instructions paraphrased from the leo project.
**Except I don't call myself guberif IRL.
***Quotation marks are necessary for any paths with spaces in them in this scenario. Just thought I'd save you some pain.

My roommates and I are behind a Linux NAT firewall, and we use Torrentflux for our bittorrent stuff. I'm tired of downloading .torrent files then having to upload them again to the torrentflux server. Soon I'll just be able to double-click on them and have them sent to the torrentflux box :D Hopefully the torrentflux people will like the script enough to include it in their distro.

There may be simpler ways to do this.

I'm unsure how this would work with multiple file selections right now. I'll find out.