41

I am creating a zip file and would like to include a link to a website within it so that users can double-click on the file and go straight to the website. In my research, I discovered that what I want is a .url file because it is cross-platform.

However, I can't seem to create one on a Mac. Whenever I drag a URL to my desktop, a .webloc file is created instead. This file is typically associated with Safari and isn't readable on Windows, so it won't work. Unfortunately, it's created even if I drag the URL from an alternative web browser, like Firefox.

According to this page, there is some non-trivial data within a .url file that makes it so that I can't just create one myself in a text editor without knowing what I'm doing. So how can I create a .url file on a Mac?

Thunderforge
  • 1,007
  • 2
  • 12
  • 18

7 Answers7

73

Add these lines in TextEdit and save as .Url

[InternetShortcut]
URL=http://www.yourfavweb.com/
IconIndex=0
Thunderforge
  • 1,007
  • 2
  • 12
  • 18
Kirk
  • 1,433
  • 11
  • 14
20

Following Kirk's answer, here is an small bash script for creating such files. Executing

url-create.sh superuser-site http://superuser.com/

creates a file superuser-site.url:

[InternetShortcut]
URL=http://superuser.com/

The url-create.sh shell script is the following:

#!/bin/bash
if [[ $# -le 1 || $# -ge 3 ]] ; then
    echo Usage: $0 '<namefile> <url>'
    echo
    echo Creates '<namefile>.url'.
    echo Openning '<namefile>.url' in Finder, under OSX, will open '<url>' in the default browser.
    exit 1
fi

file="$1.url"
url=$2
echo '[InternetShortcut]' > "$file"
echo -n 'URL=' >> "$file"
echo $url >> "$file"
#echo 'IconIndex=0' >> "$file"

PS: I don't think the IconIndex is necessary, so I commented it out.

hectorpal
  • 2,453
  • 1
  • 15
  • 14
8

On mac, without [InternetShortcut] it always opens in Safari, while including it makes the file open with the default browser.

scott
  • 81
  • 1
  • 1
3

It is sufficient to put

URL=http://www.yourfavweb.com/

in the file to make it work, the [InternetShortcut] and IconIndex seem not to be necessary (any more?).

1

In my case, without [InternetShortcut], Safari is pulled up, but no webpage is opened. With [InternetShortcut], it opens with the default browser.

Z F
  • 11
  • 1
1

It's also possible to drag & drop the URL from the browser (click on the symbol just left to the URL) into the finder which will create .webloc file that does the same..

0

Just wanted to add to this, if you use the most top option and it's your first time on mac or using Text Editor. Make sure to convert your text to flat text before you can save to .url. Otherwise it won't let you. :-)

  • 1
    Avoid posting answers to old questions that already have well received answers unless you have something substantial and new to add. – Toto Aug 19 '22 at 09:33
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://superuser.com/help/whats-reputation) you will be able to [comment on any post](https://superuser.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/1141283) – Burgi Aug 19 '22 at 10:05