Associating file extensions

asked 13 Sep '11, 08:18

Jake's gravatar image

Jake ♦♦
accept rate: 98%

This action allows you to create file associations for Windows, defining commands such as "open" for a given file extension.


icon: Path to the icon file that contains the icon to display.
friendlyName: Friendly Name for the progID.
commandList: List of commands that can be invoked on each given file type.
extensions: Space-separated list of extensions for which the given commands will be available.
progID: Programmatic Identifier to which the extensions are attached, contains the available commands to be invoked on each file type.
mimeType: MIME type associated to all the file extensions.

Supported Platforms: Windows.


        <!-- Defining the "open" command -->

For the <runProgramArguments> tag, you can use the following wildcards:

%1 : is replaced by the short name of the file being executed
%L : is replaced by the long name
%* : is replaced by the name of any arguments to the file

Note: Be careful when using %L. Eventually, any quotation marks in the value of %L are stripped off and the argument passed to the command may contain file names with spaces. Such file names can cause problems with some commands. If this is a concern, you should use %1 instead of %L.


answered 13 Sep '11, 08:21

Jake's gravatar image

Jake ♦♦
accept rate: 98%

This can also be done in linux but is much much less simple.

Here is roughly how you do it.

1) Create a 'Desktop Entry File' for your application. This is a .desktop file in /usr/share/applications/ based on the Desktop Entry Specification found at The entry must contain an entry for the Mime Types it can open.

2) Create an XML file describing the Mime Type of your file type. The file should look as follows:

<?xml version="1.0"?>
<mime-info xmlns=''>
  <mime-type type="[file_type]/[vendor]-[file_extension]">
  <glob pattern="*.[file_extension]"/>

3) Call:

xdg-mime install --mode system [xml_location]

4) Create a series of icons for the file type, usually at 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, 256x256, and 512x512.

5) For each icon call:

xdg-icon-resource install --context mimetypes --mode system --size [size_in_pixels] [icon_location] [file_type]-[vendor]-[file_extension]

6) At this point you now have a shortcut to your application, a registered mime type, and an icon for your file type. The last thing to do is register your application as the default for the mime type as follows:

xdg-mime --mode system default [path_to_desktop_entry_file] [file_type]/[vendor]-[file_extension]

7) Finally, once you have done this for every Application & File Type call the following:

update-mime-database /usr/share/mime/


update-desktop-database /usr/share/applications/

...and that should be it. Obviously, you'll need to replace everything wrapped in [] so it suits your needs. I couldn't use angle brackets so I used square.


answered 25 Oct '12, 06:39

Bob%20Gardner's gravatar image

Bob Gardner
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 13 Sep '11, 08:18

Seen: 3,337 times

Last updated: 25 Oct '12, 06:40