Parsing properties in Link- and Internet Shortcut files

R.H. roland.huettmann at gmail.com
Fri Feb 12 12:53:14 EST 2021


I am on Windows 10 (but answer will apply to MacOS as well).

I am trying to read the URL property of a file that I create simply
dragging-dropping the Internet address from my browser to the Desktop and
then storing this file. There are thousands now!!!

Some of such files are readable text files with the readable content
"[internetshortcut], URL: xxx etc." -- but most Internet shortcut files on
Windows with the invisible .url or .ink extension are empty when trying to
read with using a text editor or opening them in LiveCode.

In such Windows file's there is a property url:<link> that contains the web
address. It is visible when opening using the right mouse button (context
menu) and then selecting the "properties" item. When double-clicking such
file, the default browser will open and open the web page directed to.

But I want to read this URL property as text directly and use it from
within LiveCode.

I assume that these Internet shortcuts store the URL information not in the
file itself, or I just cannot get to this information.

I found one batch file script that promises such a solution. Such batch
text file can be called through the SHELL() command and will then execute.
It has the file extension ".bat".

#-- START BATCH SCRIPT
echo off
setlocal enableextensions enabledelayedexpansion
pushd %1
for %%F in (%1\*.url) do (
   echo %%~dpnxF
   call :findurl "%%~dpnxF"
)
popd
goto end
:findurl inputfile
set url=
for /f "tokens=2 delims==" %%i in ('findstr URL %1') do set url=%%i
echo %url%
echo -----
:end
#-- END BATCH SCRIPT

Unfortunately, my knowledge of such batch scripts is very limited.

I get error messages when calling the batch file through the shell
function. Maybe there is someone here who can interpret this script? To me
it would be sufficient to simply call shell("location of the file and file
name of the url-file .. shell commands") and receive back the URL property
as text. Or is there any other way to get to this information?

Since LC is cross-platform, such solution also would be nice to have for
OSX and Linux?

Regards, Roland



More information about the use-livecode mailing list