I have recently collected & saved a large volume of internet links on my Ubuntu 14.04 machine that I wish to share with my other computer that runs OSX, but have come to realize that Google Chrome will not open these files on OSX as it does in Ubuntu. The files are.desktopfiles. An example of the file's contents is as follows:

[Desktop Entry]
Name=Link to Lifehacker Pack for Chrome: Our List of the Essential Extensions

OSX does not know natively what to do with this file type, and prompts me to choose which application to use to open the files. If I choose to use Google Chrome it will simply display the contents of the file in a tab, but will not navigate to the url in the file. Opening the file with Firefox loads the URL fine in a new tab.

How can I get Google Chrome to open these files normally?


1 Answer 1


My primary OS is OS X, however I do have a Linux Mint system I use and run into similar situations in which I want to do the same thing on both systems, and when it's not directly supported I have to find another way. In a case such as this, if there wasn't a Browser Extension for .desktop files, like in your other question about .url files, here is what I'd do.

I'd convert the .desktop files to .webloc files and or .url files and use the Default Apps Preference Pane, RCDefaultApp by Rubicode, to change which application opens any given file extension.

Here's a bash script, that I modified from a similar script I wrote years ago, which will create .webloc files and or .url files from .desktop files that have URLs in them.

  1. In a Terminal cd to the directory containing the .desktop files.
  2. Issues the following commands:

    touch d2wu
    open d2wu

  3. Copy and paste the code below into the opened d2wu file.


echo " Create .webloc/.url files from .desktop files."
echo " ----------------------------------------------"
echo "              Choose File Type(s):" 
echo " [1] Create .webloc & .url files."
echo " [2] Create only .webloc files."
echo " [3] Create only .url files."
echo " [Q] Quit."
echo " Press 1 to 3 or Q then press Enter..."

Create_WEBLOC () {
    for f in *.desktop; do
        if [[ ! -f  ${f%.*}.webloc ]]; then
            url="$(awk -F '=' '/^URL=/{print $2}' "$f")"
            if [[ ! -z $url ]]; then
cat <<EOF >"${f%.*}.webloc"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
                echo "  No URL found in $f file."

Create_URL () {
    for f in *.desktop; do
        if [[ ! -f  ${f%.*}.url ]]; then
            url="$(grep -e '^URL=' "$f")"
            if [[ ! -z $url ]]; then
                printf "[InternetShortcut]\n${url}\n" > "${f%.*}.url"
                echo "  No URL found in $f file."

read  keypress

case "$keypress" in
        echo "  Creating .webloc & .url files."
        echo "  Creating .webloc files."
        echo "  Creating .url files."
    "q" | "Q")
        echo "  No files were created."
        echo "  Pressing \"$keypress\" is not a valid choice... Try again!"
        read -p " Press Enter to continue..."
        "$0"        # Run the Script again.

  1. Save and close the d2wu file.

  2. Make d2wu executable:

    chmod u+x d2wu

  3. Execute d2wu:


Example script output:

Create .webloc/.url files from .desktop files.
             Choose File Type(s):

[1] Create .webloc & .url files.
[2] Create only .webloc files.
[3] Create only .url files.
[Q] Quit.

Press 1 to 3 or Q then press Enter...

Note: You can use the Default Apps Preference Pane, RCDefaultApp by Rubicode, to change which application opens a given file extension.

Also, if you need modify other default methods of file types, Apps, URLs, UTIs, etc. the the Default Apps Preference Pane is a great utility for it.

Code shown in Sublime Text

Note: As coded it will not overwrite existing .webloc files and or .url files even thought when selecting 1, 2 or 3, it reports "Creating ... files.". This was done to both not step on existing files and minimize output to the screen while only outputting which .desktop files do not contain a URL=... line, as can be the case depending on what type of .desktop file it is.

  • super handy, thanks for taking the time to write this out. I was lucky enough to have a Linux guru answer my question HERE recently, so I am using that method for now. I may use this code above though at some point thank you. May 7, 2016 at 21:21
  • 1
    @Kalamalka Kid, back in Snow Leopard days I had a script I wrote that customized my Dock with 5 different backgrounds and accents to show which apps were open and I would change the Dock base on the what wallpaper I displayed. So to copy that existing script to d2wu as the template and delete/add the code as needed was a breeze. Easier for me to do then if I had to do what the Linux Guru did for you. I wouldn't have been able to do that as I'm not a Linux Guru! :) Thanks though for acknowledging my effort. May 7, 2016 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .