Making Text out of Webloc Files

Webloc files are the handy little URL “aliases” that Mac OSX makes when you drag a URL from your web browser into a file folder. I’ve used them quite a bit to organize links I want to keep for various reasons.

If you’ve ever needed to convert a directory of “webloc” files into text suitable for pasting into an email or document, you want this handy little command:

grep -h http *.webloc | grep -v | sed -e 's///' | sed -e 's/<\/string>//'

To use it, open up the terminal window, cd to the directory which has the webloc files, and type the above command. It will output a list of URLs to the shell that you can easily cut-and-paste into your document.

Update 10-14-09: Just realized that the formatting had gotten messed up in the html encoding, the posted command has been updated now to actually work.

3 thoughts on “Making Text out of Webloc Files

  1. It finally worked for me after one small change: change the first sed to sed -e ‘s///’

    thanks for the acorn!

  2. I don’t know what the first sed originally looked like, but sed -e ‘s///’ does not work for me at all. I get the error “sed: first RE may not be empty” using os x 10.6. I changed it to sed -e ‘s///’. I also replaced the second grep to grep . With the original grep, the output contained a lot of lines beginning with “Binary file” and the name of the link. Also, the original grep would eliminate any .webloc links to Apple sites. The complete command that I use is: grep -h http *.webloc | grep \ | sed -e ‘s///’ | sed -e ‘s///’

  3. Whoa! What is happening here? I just posted the above comment, but it has been altered and is not what I submitted. Important text has been filtered out. Try the following:


    The underscores are for legibility and should be interpreted as no space.

Comments are closed.