We all know Microsoft tries to create “standards” rather than follow them, and when this interferes with other programs, protocols, technologies and such, people tend to blame the other party. A good example is the horrid .url format Internet Explorer uses for web shortcuts you save on the desktop, etc, in Windows. When people change to Firefox as the default browser, they’re often upset to find it won’t open .url files, as it doesn’t know what to do with them.
While you could argue that in this day and age of Microsoft dominance, Firefox should be adding support for everything to do with Internet Explorer, it should be pointed out that the vast majority of users don’t create internet shortcuts on their desktop, but use a concept called “Favorites” (“Bookmarks“ everywhere else). In over a decade of using Internet Explorer (IE), I never saved a single one – I mean, why would I when I had a Favorites menu?
But the fact remains that there are many people out there who, rather than create bookmarks for their sites, save links on their desktops or in sub-folders of My Documents. And when these people migrate to Ubuntu, they expect to be able to open them, unaware it is a Microsoft-only format (which, if I must point again, is actually a shortcoming of IE).
But there is a way to open these .url shortcuts in Ubuntu by adding support for it in Firefox yourself. While it takes a little fiddling, it’s not that hard if you follow the steps outlined. Basically, you’ll need to create a script to handle this task, make the script executable (then copy it to a system folder), create a symlink to it, then create a mimetype to recognise .url files. Don’t worry if that sounds too technical, as even if you knew what all that meant, you’d still need to follow these instructions.
So, firstly, designate a folder for the script to reside in (create one if need be; eg: /home/yourusername/Settings/Scripts), and open it. Right-click an empty area of the folder and choose Create Document > Empty File. A new blank text file with the generic name “new file” will be created; you’ll notice the name will be highlighted, meaning you can type the new name in, so type in fx-url, then hit Enter to finalise it. Double-click the file (or just hit Enter again if it is still selected) and paste the following script code into it:
#!/usr/bin/perl
# Script to make Microsoft Windows Internet Shortcuts (*.url) work on Linux.
# Open up the file
open(F,"<$ARGV[0]") or die "$0: Could not load Internet Shortcut file $ARGV[0]!\n";
# Find the URL
while($in = <F> and not $url) {
chomp($in);
if($in =~ m/\s*URL\s*\=\s*\S*\s*15*/) {
$url = $in;
$url =~ s/\s*URL\s*\=\s*//; # Filter out the beginning stuff
$url =~ s/\s*15+//; # Filter out the nasty DOS carriage return!
}
}
system "firefox $url &";# or die "$0: Could not open $netscape\n"
Once you have exited and saved the script, you’ll need to make it executable so that it can run like a program. Open a terminal in the folder the script is in, and enter the following:
sudo chmod a+x fx-url
You’ll now need to copy the executable script to /usr/bin, so enter the following into the terminal:
sudo cp fx-url /usr/bin/fx-url
To create a symlink to fx-url in /usr/bin, enter the following command into the terminal:
sudo ln -s /usr/bin/fx-url /usr/bin/'Web Shortcut Browser'
This symlink step is not essential, but it allows you to specify the name that appears in the context menu when right-clicking on .url files. This way, you’ll see a menu item that says “Open with Web Shortcut Browser“, instead of just “fx-url“. Since you are only renaming the symlink, you can choose whatever name you’d like to see in the context menu; just replace the text “Web Shortcut Browser” in the above command with the name that you prefer.
Now you have to create a mimetype for the .url extension, so you’ll need assoGiate (read this for more info).
Open Applications > System Tools > File Types Editor, and click the New button. Enter the following information in the corresponding tabs:
► General:
Category: Text and source code
Name: x-url
Description: Microsoft Internet Explorer Shortcut
You can choose an icon for the .url file-type via the browse button […] – if you don’t have any, there are some at the bottom of this post that you can save to a folder like /home/yourusername/Settings/Icons.
► Filenames:
Filename pattern: *.url
► File contents:
When you click +Add, you’ll see more than one data entry field, but all you need to worry about is the Value: one.
Value: [InternetShortcut]
Now your system knows what .url files are, but it still doesn’t know what to do with them. You now have to associate the .url extension with the executable script fx-url, so right-click any .url file and go to Properties > Open With. Click the Add button, and at the bottom of the “Add Application“ window you’ll see the “Use a custom command“ option; click this, then either browse to /user/bin and select the symlink you created, or enter /usr/bin/Web Shortcut Browser (or the appropriate name if you changed it). Click the Add button to save your changes (but leave the “Properties“ window open as you’ll need it in the next step).
Now you need to make the associated action the default option for double-clicking, otherwise you’ll have to right-click .url files and choose the required option from the context menu. To make opening in Firefox the default action, in the Open With tab of the “Properties“ window, click the dot to the left of the entry you just added (eg: “Web Shortcut Browser“), then click Close.
Next, open any Nautilus (file manager) window and go to Edit > Preferences > Behaviour. In the “Executable Text Files“ section, make sure that “View executable text files when they are opened“ is selected. Click Close, and it is done (you may need to log out or reboot for the changes to take effect). Now when you right-click any .url file, you should see “Open with Web Shortcut Browser“ as the top entry of the context menu, and it will be the default action for double-clicks.
Some Issues You May Come Across:
Error Opening .url Files in Firefox
If Firefox opens when you double-click .url files, but instead of going to the web page, it gives you this error message:
Firefox doesn’t know how to open this address, because the protocol (basehttp) isn’t associated with any program.
… then there is an issue with the code in the .url files themselves. If you open an .url in a text editor, you will see something like:
[DEFAULT]
BASEURL=https://ubuntugenius.wordpress.com/
[InternetShortcut]
URL=https://ubuntugenius.wordpress.com/
IDList=
IconFile=http://www.gravatar.com/blavatar/b040b12c9e739ace052197f85996bd27?s=16&d=https://s-ssl.wordpress.com/favicon.ico
IconIndex=1
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
Basically, it means the first 2 lines are interfering, so will need to be removed, as they are not needed (and obviously causing problems). But you won’t have to do so manually, as we can delete the offending lines from all your .url shortcuts with one command. Open a terminal in the folder with all your .url files, and enter the following:
sed -i "1,2 d" *.url
That command that only edits .url files, removing the first 2 lines of each, then saves each file. They’ll open fine in Firefox now.
Specified .url Icon Doesn’t Appear
If the icon you picked for the .url file-type isn’t showing, but is a generic text icon, you’ll probably find this is only the case with Nautilus, the default file manager in Ubuntu. If you have another like Thunar, you should see your icon displayed without issue. While this doesn’t really help the majority of Ubuntu users, I should point out that once you’ve opened each .url in Firefox, and bookmarked them all, you won’t really need to hold onto your old Internet Explorer shortcuts anyway.
But if this is bugging you, try updating the system icon cache with this command before rebooting:
sudo update-mime-database /usr/share/mime/
(This probably won’t do much if you have this error, so when I can figure out a fix I’ll update this tutorial)
≈≈≈≈≈≈≈≈≈≈≈≈
Here are a few icons for the .url mimetype:
☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻
Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!
Good idea but can’t get it to work on Ubuntu 9.10, done everything to the letter, url scripts are correct format, but when I open a url file… nada, nothing happens :-(
Stupid microsoft!
Hmmm… no other info other than they don’t open? Damn, I was hoping this would work for everyone, especially since I added the bit about editing URL files if they won’t open in Firefox (which wasn’t an issue before, but in 9.10 i tis, at least for me). And yeah, stupid Microsoft, who love creating standards rather than follow them. But I suppose playing nice and fair isn’t a great strategy when trying to maintain a monopoly, hehe. I’m so glad Firefox finally surpassed IE as the most used browser, meaning even many newbies went out of their way not to use the browser they got with their OS.
But personally I think people have to get out of this thing of saving shortcuts to the desktop, as generally they’re only going to work with one browser, and in future you can have hassles like this. “Bookmarks” menu, guys! Then you can export them to other browsers too (which is handy for people like me who often use 3 browsers at a time).
It didn’t work here too :( Tried on Ubuntu 10.04 Lucid Lynx but, like Paul said, nothing happened. I know you did your best and the intentions were good, but something is missing. Well, I quit. And I wish this option will be available soon by default. Your method is too complex lol :) Thanks anyway and good work.
Yeah, that’s weird, and I have no idea why this is happening on some PCs. I’ve done this to a few with different versions of Ubuntu, and always successfully. Go figure. But don’t hold your breath on a default option for this – .url files are a Microsoft beast, and most people don’t use them in IE, but create bookmarks (oops, sorry add as “favorites”). Sorry to say, there’s just no real reason why they should. Of course, if enough people complained or asked for this in future releases, then they would; the fact that this hasn’t happened is pretty much evidence only a few people are missing this.
mayby the problem is in coding, the difference is in this sign
#!/usr/bin/perl
# Script to make Microsoft Windows Internet Shortcuts (*.url) work on Linux.
# Open up the file
open(F,”<$ARGV[0]") or die "$0: Could not load Internet Shortcut file $ARGV[0]!\n";
# Find the URL
while($in = and not $url) {
chomp($in);
if($in =~ m/\s*URL\s*\=\s*\S*\s*15*/) {
$url = $in;
$url =~ s/\s*URL\s*\=\s*//; # Filter out the beginning stuff
$url =~ s/\s*15+//; # Filter out the nasty DOS carriage return!
}
}
system “firefox $url &”;# or die “$0: Could not open $netscape\n”
Can you please point out the “difference” in the “sign”? Cheers
the same happen in my previous post :)
I try werbously: the problem is in literal -quota-
Look at 4 line in the script: column 8 and 18
this sould be the same literal it is NOT
Can you explain further? Like, perhaps point out the offending text (talking column numbers doesn’t help me, I’m afraid) and the replacement for that incorrect code? And sorry, have no idea what you mean by “literal”.
OK guys, it turns out this has all been caused by an annoying WordPress feature, which is autoformatting single- and double-quotes to “smart quotes”, which turns them from “straight” quotes to “curly” quotes. This is a feature WordPress knows full well totally messes up commands and code that would be copied and pasted, yet besides the millions of Google hits on this subject (MANY aren’t happy with this), WordPress not only stands by this, but also don’t allow this to be disabled!
So, basically, commands/code can’t work if there are incorrect characters in them, which is what happened here.
I have now manually gone through my blog looking for terminal commands and config file code that have quotes in them, and converted them back to their intended characters.
Sorry about any headaches this has caused, but, you know, I didn’t ask for this to happen (ie: blame WordPress, hehe!).
Worked great for me, thank you
Still not working for me; clicking the file opens the browser (or a new tab if the browser is already open) but not the address – it just opens my home page. Stumped.
try substituting this script:
#!/bin/bash
# Script to make Microsoft Windows Internet Shortcuts (*.url) work on Linux.
url=”`tr –delete ‘\r’ <"$1" |sed '/^URL/!d;s/^URL=//'`"
firefox $url &
I hope WordPress won't autoformat my script ;)
Marco
Almost the same as Marco’s solution:
I created a script that reads Windows shortcut and gets the URL, which it then passes to the browser:
/opt/google/chrome/chrome `grep ‘URL=’ “${1}” | awk -F”=” ‘{print $2}’`
I then right-clicked on a Windows .url shortcut, chose Options -> Open With and added the script path to the list of applications. So now double-clicking the shortcut works as it does under Windows.
Cool! Thanks for sharing that!
Great goods from you, man. I have understand your stuff previous to and you are just extremely fantastic.
I actually like what you’ve acquired here, certainly like what you are stating and the way in which you say it. You make it enjoyable and you still take care of to keep it smart. I can’t wait to read much more
from you. This is really a terrific web site.
Many thanks for your kind words! I do try my best to make informative and easy-to-understand guides that answer all possible questions. I’ll resume doing those once I’ve gone through the hell of moving house next week! Cheers.
Looks good but doesn’t work (ubuntu lusid).
Hmm, should work in Lucid – check you did everything correctly. Also, read through the comments as there are other solutions.
In Precise Pangolin 12.04 LTS, I wasn’t able to add a custom file association. The explanation (new Gnome default desktop) and an alternative procedure (mimeopen -d) are posted at http://ubuntuforums.org/showthread.php?t=2001865&p=12018776#post12018776
I found this script posted at http://ubuntuforums.org/archive/index.php/t-1338317.html which since it’s ubuntuforums and not wordpress, the script wasn’t reformatted, so copy from there.
The poster there was a bit perplexed about not being able to open .url files that have a BASEURL= in it, there’s a couple of different ways to handle that, but I changed the regexp that matches the “URL=” to skip the “BASEURL=” by anchoring the “URL” with “^URL”
[CODE]if($in =~ m/\s*^URL\s*\=\s*\S*\s*15*/) {[/CODE]
Thanks for finally writing about >How to Open .
url Internet Explorer Shortcuts in Ubuntu Using Firefox | Ubuntu Genius’s Blog <Liked it!
Hello, thanks for the idea!
Your script did not work with one of my .url file so I implemented my own version using Node.js (I don’t know Perl so I oculd not find the problem). I hope it is not a problem for you, my work is available here if you want to take a look: https://github.com/cGuille/msurl
I love your blog.. very nice colors & theme.
Did you make this website yourself or did you hire someone
to do it for you? Plz answer back as I’m looking to create my own blog and would like to know where u got this from. appreciate it
WordPress.com – just pick a theme, and start typing. It’s a free blog site.
My brother suggested I might like this blog. He used to be entirely right.
This put up truly made my day. You cann’t consider just how much time I had spent for this information! Thank you!
From the time when this article was written, a few things became different in Ubuntu 14.04. However even with slightly different menu terminology, I was able to follow all instructions until I came to this text :
Open Applications > System Tools > File Types Editor, and click the New button.
I could not find the application File Types Editor, to proceed any further.
To make things easier I installed ‘ClassicMenu Indicator’ available at the Software Center. (RECOMMENDED)
But even then, the editor it is not available under menu System Tools. Someone has the answer ? Thx
OK, perhaps you missed the line above that step:
Now you have to create a mimetype for the .url extension, so you’ll need assoGiate (read this for more info).
Here is the link for installing assoGiate, which is “File Types Editor”: https://ubuntugenius.wordpress.com/2009/11/19/create-your-own-file-types-in-ubuntu-with-assogiate/
Thx for your efforts and time ! But I there is some installation problem with assoGiate. I made a screenshot of the installation via Terminal. I will try to upload that screenshot.png and publish the link here.
(However at my own IP dedicated webspace there is some problem right now. Any preferred hosting site for Ubuntu user’s pictures ?)
I have countless internet links (Microsoft “url ‘s) saved in WinXP Favorites. If that difficult to access them with Ubuntu, that would be a NoGo for me to proceed any further. With OSX (also unix based) it is a piece of cake (on my old Macbook).
Canonical certainly will not encourage Windows users to migrate with this attitude. The whole world speaks with terminology ‘url’ as a synonym for internet link addresses. Ubuntu seems to persist ignoring this as a fact.
OK, not sure why you’re having problems installing assoGiate, but rather than try to stick up a screenshot, you should just copy and paste the terminal output (though not sure I can help with an install issue).
As for the whole URL thing, while 95% of computer users run Windows, less and less use Internet Explorer, it’s actually a very small percent of those that do that will “save” links as .url files on the desktop or whatever – by far the majority of people use the Bookmarks/Favourites feature of their browser, and rather than have links scattered all over the place as individual files, have them neatly in sub-menus of Bookmarks/Favourites.
OK, now you’re saying that all the links saved in Windows/IE Favourites are in the .url format, so obviously this is an issue for anyone migrating from IE, but failing to *fix* the situation by installing something like assoGiate to handle the filetype, I don’t think all is lost. I mean, while the following isn’t the *ideal* solution, it’s hardly much more hassle, and will ensure you don’t need to give up on Ubuntu simply because of a few links:
Open those .url files in a text editor, copy the url you find inside, paste it into Firefox or your preferred browser, and bookmark it.
Or, since you say you have a lot of those files, you can export your Favourites from IE/Windows and then import the resulting files into Firefox:
In IE:
File > Import/Export > Export to HTML file
then in Firefox:
Bookmarks > Show All Bookmarks > Import & Backup >Import HTML… = From HTML file
And just to clarify, while the world does refer to a web address as an URL, only Microsoft and its notorious Internet Explorer actually saves bookmarks as .url files, so it’s actually a case of the default Windows web browser bucking the convention of the whole world and doing things its way (once again, hehe). Most browsers, including all other Windows ones besides IE, save links as HTML files. So, rather than Firefox or Ubuntu being at fault, you can actually blame Microsoft for this.
I sent a mail to the person who is in charge of maintenance for “assogiate” to enquire why there are possible problems to install it. I received the following answer :
Quote :
“AssoGiate is no longer part of Ubuntu, because I think this software is
not useful anymore. So you cannot install it using synaptic and there is
no easy way to install it. I don’t know what you’re trying to do, but I believe it would be easier for you to use another software which can do the same job.
Best regards,
Vincent Legout ”
So I’m stuck for now in the middle of the whole procedure.
Remark : At the downloadpage , there are still three downloads available for the same latest version, without suggestion how to choose from. Anyway I think it is pointless to continue with assoGiate.
Again, with my Mac, it is a piece of cake to open all .url’s.
We may consider Microsoft being guilty of not following of industrial standards, But Canonical should not consider to be more catholic as Apple. Again, to ignore others completely is not the most clever idea to encourage users to switch to Linux opensource.
I still have the option to export/export links as you advised.
However I would have been happy to use the folder Favorites “as bookmarks”, like some browsers allow that option in Windows. No need to import/export. just bookmark any webpage into Favorites.
One reason more I’m using Favorites for much more than for internet links only. It is just another folder not very different as any other, and it can be accessed from Ubuntu as well as from Windows.
Georges
This excellent website truly has all of the information I wanted
concerning this subject and didn’t know who to ask.
[…] you require linux support for the solution below, please see this article. * I have no connection to the article, […]
[…] you require linux support for the solution below, please see this article. * I have no connection to the article, […]