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.