Parsing properties in Link- and Internet Shortcut files

R.H. roland.huettmann at gmail.com
Sat Feb 27 02:41:02 EST 2021


Dear Hakan

Thank you very much for this information. As you may have noticed, I had
solved the problem using the Batch file the same day I posted the question
for Windows.

For Mac, I had no idea and your input is highly appreciated. For Linux I
also do not know.

Actually, these special files on Windows (with the hidden ".url" extension)
are usually fine to read simply using URL("binfile:" & tFilePath ). My
problem has be with a number of files that returned empty for unknown
reasons.

It is a more difficult to parse "shortcut" or ".lnk" files in Windows since
they have a binary format and to extract relevant information requires
knowing the detailed file structure and reading relevant bytes or trying a
hack to extract the readable links they represent without (which I did so
far). Also for these files, Windows hides the extension ".lnk", but it is
visible when calling files (tFolderpath) in LiveCode.

Happy weekend
Roland

On Fri, Feb 26, 2021 at 2:52 PM <hakan at exformedia.se> wrote:

> On macOS URL link files are stored as a plist-file like:
> <?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://lessons.livecode.com/</string>
> </dict>
> </plist>
>
> So you can open the file as text and then parse the content.
>
> :-Håkan
> On 12 Feb 2021, 18:55 +0100, R.H. via use-livecode <
> use-livecode at lists.runrev.com>, wrote:
>
> 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
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


More information about the use-livecode mailing list