Parsing properties in Link- and Internet Shortcut files -- SOLVED for Windows 10 -- Added remarks

R.H. roland.huettmann at gmail.com
Fri Feb 12 17:49:31 EST 2021


Hi there

Windows 10:

The .bat file is required for those .url files that do not give you a text
when opening (and that was the problem).
Some of the .url files can also simply be read using this sample script.
(And these specific files cannot be read with the .bat file as I seem to
recognize. Further testing is needed.)

on mouseUp  local tFilePath
 ask "Please paste the file path"
 if it is not empty then put it into tFilePath
 put URL("binfile:"&tFilePath) into msg
end mouseUp

You must provide the filepath with the filename.
The result (as an example):

Example output for .url file (same file not readable with the .bat)
   [InternetShortcut]
   URL=https://cosi.lino-framework.org/tour/index.html

Greetings, Roland


On Fri, Feb 12, 2021 at 11:11 PM R.H. <roland.huettmann at gmail.com> wrote:

> Tested on Windows 10:
>
> I now found and tested the batch file script that works now:
>
> Create a batch file, for example "GetURL.bat"
> Edit the file with a text editor (Notepad++ or whatever)
>
> Put the following script into this file:
>
> :: START OF SCRIPT -- comment line
> @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 OF SCRIPT -- comment line
>
> Save the file and place it for this demo in the C:\folder (which is
> accessible for admins only. Otherwise use a "documents/..." folder.
>
> -- Usage
> When calling the .bat file here we assume that the .bat file is in the C:\
> directory .
>
> ...Calling from Windows CMD opened with Administrator rights:
>  C:\GetURL.bat "C:\Users\<your username>\Desktop\Links"
>
> This assumes that there is a folder "Links" on the desktop containing the
> Internet shortcut file (hidden file extension .url) and that you want to
> read the content of the URL plus the filename.
>
> -- Now, we can call the .bat file from LiveCode with a little script in a
> test button:
>
> on mouseUp
> # Example script to call the .bat file:
>    set the hideconsolewindows to true
>    put "C:\GetURL.bat" into tCmd -- Calling the commands in the .bat file
>    put "C:\Users\Rolan\Desktop\Links" into tFolder -- The folder
> containing Internet Shortcut files .url
>    put tCMD && tFolder into tCommand
>    put shell (tCommand) into msg --x Could be messages box or any field...
> end mouseUp
>
> -- Example output in the message box  (a list of .url files with the
> content of their url)
>
> The script in the .bat file looks at all files with a .url extension in
> the folder specified and returns the name and the URL content of that file.
> Each record is separated by three "---".
>
> C:\Users\Roland\Desktop\Links\simultaneous multiple database access -
> LiveCode Forums.url
> https://forums.livecode.com/viewtopic.php?t
> ---
> C:\Users\Roland\Desktop\Links\Sons of Thunder Software - Developer
> Resources - LiveCode.url
> http://www.sonsothunder.com/devres/livecode/livecode.htm
> ---
> C:\Users\Roland\Desktop\Links\Sons of Thunder Software - Products.url
> http://www.sonsothunder.com/products/products.htm
>
> ---
>
> Please, if there is anything for Mac (OSX) and Linux, we could publish
> this in the Forum.
>
>
> Roland
>
> P.S: I will also check how to read the local .ink files that are shortcuts
> to files and folder in Windows. It should also be possible using this for
> ".ini" files.
>
>
>



More information about the use-livecode mailing list