How to Convert webloc to url

Because this issue has driven me mad for the last couple of days and because I was not able to find an easy solution, I now like to post the solution my son created for me!


I now have simpel QuickAction at my disposal with which I can convert any selected *.webloc file to a *.url file :-)

This enables me to select any number of *.webloc files in a folder and select the QuickAction 'webloc2url' I created like this:



We first created an automator workflow to test the script and than converted the workflow to a QuickAction.

The Workflow hat only 2 elements:

  • Get selected Finder Items
  • Run Shell script


The text inside the code field for the script:


for p in "$@"; do

echo "Found webloc: $p"

## $p: ./some/dir/link.webloc

DIR=$(dirname "${p}") ## ./some/dir

FILENAME=$(basename "${p}") ## link.webloc

FILENAME_BASE=$(basename "$FILENAME" .webloc) ## link


TEMP_FILE="$DIR/temp_link.url.$$.tmp" ## ./some/dir/temp_link.url.2342343.tmp


FILEPATH_url="${DIR}/${FILENAME_BASE}.url" ## ./some/dir/link.url


## remove any "._XY" files - AppleDouble encoded Macintosh file

## see: http://en.wikipedia.org/wiki/AppleSingle_and_AppleDouble_formats

dot_clean -m "$DIR"


LINK=`plutil -convert xml1 -o - "$p" | grep "string" | sed "s/<string>//" | sed "s/<\/string>//" | sed "s/ //"`

echo " - Link is: $LINK"


echo " - Create Windows url file"


echo "[InternetShortcut]" > "${TEMP_FILE}"

echo "URL=$LINK" >> "${TEMP_FILE}"


mv "${TEMP_FILE}" "${FILEPATH_url}"


done


echo "all done."


## EOF.



Hope this helps anyone who is struggling with this annoying issue!


It does not delete the webloc files automatically on purpose, feel free to add that commend if you want (I simply search for all webloc files in a folder and delete these manually once I am sure I converted them all)

There is no check on the file type, so we take not responsibility on whatever happens if you select a file other than *.webloc.


Feel free to use this on your system, but always at your own risk. It works fine with the current macOS version 12.01 but I am not responsible for any glitches in combination with earlier or future versions or macOS.


Hope this post makes fellow cross-platform users happy.

Posted on Jan 7, 2022 10:35 AM

Reply

Similar questions

3 replies

Jan 7, 2022 1:22 PM in response to goudinchen

Hi, thanks for posting the unique way to do it, kudos! :)


You can also just drop the .webloc file on Text Edits iCon to see & copy the url...


<?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">

<dict>

<key>URL</key>

<string>https://forum.xojo.com/t/os-x-how-do-i-create-a-webloc-file/11652/2</string>

</dict>

</plist>

Jan 9, 2022 6:07 AM in response to goudinchen

This is just what I needed!

We collect URL's for creative ideas in separate folders per project. When I do research at home on my mac, neither myself nor my colleages were able to simple open the stored urls by clicking the *.webloc files under Windows.

Running scripts in the terminal is not something that comes fluently to me and opening the webloc files in a text editor first ist just to time consuming if you want to quickly leaf through dozens of collected ideas...

The resulting url files can be opened both by Windows and macOS so I really do not understand that mac-based browsers do not offer an option in which the user can specify that url links should be stored in a compatible *.url format for simple collaboration with Windows users.

After storing one or more links inside a project folder while at home, I no simply make a right-click and run my brand new QuickAction webloc2url :-)


Thanks a million!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to Convert webloc to url

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.