Hack 66 Anatomy of an Internet Shortcut


Under the covers, an Internet Shortcut is a perfectly ordinary text file with little in the way of magic.

Drag a Uniform Resource Locator (URL) from your browser's address bar to the desktop and OS X kindly creates an Internet Shortcut (Favorite, if you're coming from the Windows world), something.url, for you. Double-click or drag the shortcut back into your browser and you're returned to the URL you were visiting.

Under the covers, an Internet Shortcut is a perfectly ordinary text file with little in the way of magic. A shortcut to the Apple web site, for instance, looks like this:


66.1 Editing an Internet Shortcut

Editing an Internet Shortcut is simply a matter of opening it up in your favorite text editor, altering the URL, and saving it. Introducing an extra space here or blank line there will render the shortcut inoperable, so tread carefully.

66.2 Creating an Internet Shortcut

Building a new Internet Shortcut from scratch is a simple affair. Fire up a text editor, type the requisite incantations, and save. Name it anything you like, but you should tack on a .url file extension [Hack #6]. The first line should read:


The second line is the URL itself, prepended with URL=. A shortcut to the O'Reilly Mac DevCenter would read:


Any valid URL will do, whether pointing to a web site (http:// . . . ), FTP site (ftp:// . . . ), email address (mailto: . . . ), or whatnot ? just so long as your browser knows what to do with it. A shortcut to the mailto:president@whitehouse.gov email address would, via your browser, create a new email message to the president using your default mail application:


You can actually embed more complex addressing and a subject in a mailto: shortcut, like so:

URL=mailto:president@whitehouse.gov?cc=ex-president@whitehouse.gov RETURN

The URL . . . "Transitions" line was split for the purposes of publication; be sure to join them for your shortcut to work as expected.

Whether editing an existing or creating a new Internet Shortcut, you should be aware that each text editor has its own peculiarities when it comes to editing Unix and special files [Hack #51]. Some alter the line break [Hack #5] character; others, the Creator and Type codes [Hack #6]; and still others fiddle with both. The correct line break should be the Mac's preferred ^M. The file code should be LINK. The creator code should be that belonging to your default web browser (e.g., MSIE for Microsoft Internet Explorer).

You may find that your shortcut won't work because of line-break issues [Hack #5]. Also, you may need to bless the file as an Internet Shortcut and associate it with your preferred web browser[Hack #6].